RE: [PHP] Smarty Tips and Techniques

2009-03-20 Thread Robert Cummings
On Thu, 2009-03-19 at 22:54 -0400, Bob McConnell wrote:
 From: Robert Cummings
 On Thu, 2009-03-19 at 12:14 -0400, Bob McConnell wrote:
  From: Bastien Koert
   On Thu, Mar 19, 2009 at 11:06 AM, Bob McConnell r...@cbord.com
 wrote:
   
From: Virgilio Quilario
 
 Most discussion clipped for brevity
 
  // OOP
  
  class DbFireman extends DbPerson
  {
  private $fireman;
  
  function DbPerson( $id )
  {
  parent::__constructor( $id );
  $this-fireman = load_stuff_for_fireman_from_db();
  }
  
  function getStationId()
  {
  return $this-fireman['stationId'];
  }
  
  function setName( $name )
  {
  $this-fireman['stationId'] = $stationId;
  }
  }
  
  $fireman = new DbFireman( 1234 );
  $fireman-setStationId( 'Bob' );
  echo $fireman-getStationId();
  
  ?
  
  So as you can see they're almost identical except that the OOP version
  of fireman didn't need to redeclare functions. True you could have
  skipped doing that if you just used the person functions, but then you
  may introduce onconsistencies. Additionally, the class version ensures
  that the methods applied are those bleong to the concept of fireman
  whereas passing data structures around can easily get confusing,
  especially if you choose to allow the person functions to be applied
 to
  the fireman. Going futher, using OOP let's you do all sorts of generic
 
 Hi Rob,
 
 Unfortunately, you still don't understand the problem I have. While it
 takes a while to puzzle out the details, I don't have any trouble
 reading, understanding or debugging code like this, even though you
 skipped completely over several major components (*). I have even
 modified existing methods and made minor adjustments to classes, _once
 they have been written_.
 
 What I can't do is take a problem description and turn it into classes
 that will actually solve the problem. I can usually turn it into
 procedures relatively quickly. I can and have built real-time,
 multi-tasking and multi-threaded applications on a variety of kernels
 and operating systems with no significant trouble. I have written device
 drivers, interrupt service routines, message queues and I/O buffering
 routines without spending a lot of time thinking about them.

Aaah, you're stuck in procedural mode. In my first year of university
they taught us both C and Smalltalk in different courses and during the
same semester (same semester for me anyways). As such, I didn't form a
bias. Unfortunately they taught us scheme the following year and while I
understand scheme, I have less of a liking for it :)

 But defining objects and then figuring out how to create and use them
 completely escapes me. My mind simply won't map a problem into objects,
 it only sees procedures. Even when I look at classes, they resolve only
 as loose groupings of functions and variables, not as unified
 components.

And what is a library to you? And a library for which each function
requires on being passed a specific structure type? The structure is
merely the object, and the library routines are the methods. if you can
see libraries and structures, then you can see classes and methods.

 If anyone knows how to fix that, please tell me. In the meantime, in my
 continuing effort to eschew obfuscation, I will stick with procedural
 programming.

It's not for people to tell you how to fix it... it for you to unwire
your head and learn it yourself :)


 (*) For example, $this- suggests you have added an array of pointers.
 Some are pointers to functions (aka methods) others are pointers to
 variables (aka members). [--SNIPPITY--]
 
 You also failed to explain what new does, or parent::__constructor.
 What is the relationship between a class and an object? [--SNIPPITY--]

I wasn't teaching your OOP, I was showing that OOP and procedural are
merely different representations of the same thing, and that the
representations aren't all that different.

  I get frustrated
 because of the extra overhead required to instantiate an object with its
 members before they can be referenced,

If you've done C programming then you know you have to instantiate a
pointer to a structure before you should access any of it's members.
Whether you zero out the memory or actually assign values... you are
still instantiating.

  instead of simply being able to
 use them at any time from anywhere in my code. Likewise, having to pass
 a pointer for one object to another object before the second can call
 the first is also counter-intuitive. They're all part of the same
 application, why doesn't the compiler take care of those details like it
 should?

I'm not sure what you mean in the above.

 Obviously, I don't expect answers for these questions, but hopefully
 this will give you a better understanding of the greater issues
 involved. This is a far cry from the Fortran IV I was taught in college
 40 years ago. B.M.

I'm sure that's a good thing :)

Cheers,
Rob.
-- 

Re: [PHP] Smarty Tips and Techniques

2009-03-20 Thread Thodoris



From: Bastien Koert
  

On Thu, Mar 19, 2009 at 11:06 AM, Bob McConnell r...@cbord.com wrote:

From: Virgilio Quilario
 That looks nice, but how do I get to the point where I can


understand
  

 how to use it?

 I have also looked at the Smarty site


http://www.smarty.net/, but
  

 their documents assume significant experience in building and


using
  

 templates.

 Where can I find guidance or tutorials on how to do all of


this,
  

 starting with only a rudimentary knowledge of HTML and PHP.


It would
  

be
 best if they also focused on procedural rather than object


oriented
  

 code.


 When I started learning smarty, I spent most of my time doing


research
  

 and that's really tiresome and it is so hard to find examples.
 Experimented a lot and listed those what's possible, then


applied them
  

 to my projects.

 Now to make them handy I posted them to my site so i can have


a look
  

 whenever and wherever.




http://www.jampmark.com/php-programming/16-very-useful-smarty-scripting-
  

tips-and-techniques-to-make-templates-smarter.html


http://www.jampmark.com/php-programming/16-very-useful-smarty-scripting
-tips-and-techniques-to-make-templates-smarter.html 
  


 As a first step, maybe you should see the crash course at


smarty
  

 http://www.smarty.net/crashcourse.php

Hi Virgil,

After your last post here, I looked at your site, then the


Smarty site.
  

That was what triggered this question. Templates are a black art


to me.
  

I don't even know where to begin to understand them. Every


reference I
  

have looked at so far assumes that I already understand the MVC


pattern,
  

which is also one of the dark arts.

Let me put it simply. I can't grok OO. I tried to do OOP for


several
  

years, but it simply does not make any sense to me. As a direct


result,
  

I don't understand the concept nor application of patterns. So


how do I
  

figure out how to use templates without having to absorb those


first?
  

Can I learn enough this way to determine if a site can be


converted from
  

the current state (PHP and XHTML spaghetti) into templates and


begin
  

that transformation?

Bob,
 
You really would need to learn those concepts first OOP / MVC. There


is
  

 a learning curve, but you really don't need OOP to be able to do an


MVC
  
 style application, but it does make the code neater. 
 
One of the books that really helped me grok OOP is Head First


OOP...another
  
is Martin Fowlers Patterns of Enterprise Architecture. 


The MVC pattern is explained well in a number of places, but worth
 checking out are both the cakephp framework site and the codeingniter


site.
  
 
You'll find that there are people from both camps here, pure OOP and


other
  

just as happy with procedural coding styles. Many use both, using


objects
  

to handle common tasks like DB interaction or filesystem processes.



Yes, I have to deal with both camps here as well. Of five developers
doing PHP at the moment, two are primarily using OOP. But I spent 3.5
years as part of a team developing MS-Windows services in C++. After all
that time, I was only able to write basic functions for others to
convert into methods or classes. I could eventually find my way around
in some of those classes, but it seemed that every time I figured out
what was where, somebody refactored a major component and I had to
start all over again. All I saw was a lot of unnecessary overhead and
obfuscation which made little sense in the long run and slowed down both
the development and the application. The result was a handful of DLLs
that are shared between several products, and each time anything is
changed in one of them, every product needs to be retested to make sure
nothing got broke and some have to be recertified for PCI-DSS as well.

So you are telling me that I can forget about trying to use templates.
Since I can not understand OOP, there is no chance I will be able to use
them.

Just knowing that will probably save me several weeks of frustration.

Thank you,

Bob McConnell

  


Well think of the positive side that you don't need to write in OOP in 
order to use Smarty. Think it just like a class used for displaying the 
output (simply put).


At least I've been doing this for some time now (the non-OOP part).

I have a feeling that someone coming from the procedural way of 
programming would have problems probably with the templates instead of 
the development part.


--
Thodoris



Re: [PHP] Smarty Tips and Techniques

2009-03-20 Thread Virgilio Quilario
 Hi Virgil,

 After your last post here, I looked at your site, then the Smarty site.
 That was what triggered this question. Templates are a black art to me.
 I don't even know where to begin to understand them. Every reference I
 have looked at so far assumes that I already understand the MVC pattern,
 which is also one of the dark arts.

 Let me put it simply. I can't grok OO. I tried to do OOP for several
 years, but it simply does not make any sense to me. As a direct result,
 I don't understand the concept nor application of patterns. So how do I
 figure out how to use templates without having to absorb those first?
 Can I learn enough this way to determine if a site can be converted from
 the current state (PHP and XHTML spaghetti) into templates and begin
 that transformation?

 Thank you,

 Bob McConnell


HI Bob,

Smarty templates are just html files with placholders or variables and
simple constructs.
This was made to allow web designers to work on a page without having
to know PHP programming.
Smarty is not an MVC.
It is just a class that provides all the necessary functions to
replace variables and execute constructs in html page.
You just create an instance, set necessary config, do your PHP stuff,
assign values to template variables, and finally display.
It's just a matter of understanding how its functions or methods work.
You don't have to learn OOP and it is not about OOP or MVC.
It is just a convenient placeholder of functions necessary to run
smarty templates.

Spaghetti style programming can be very hard and really time consuming
to follow and convert.
Just take one step at a time.

Maybe I could write a tutorial for this.
Just need to find some spaghetti code for the  example.

Regards,
Virgil
http://www.jampmark.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Smarty Tips and Techniques

2009-03-19 Thread Virgilio Quilario
 That looks nice, but how do I get to the point where I can understand
 how to use it?

 I have also looked at the Smarty site http://www.smarty.net/, but
 their documents assume significant experience in building and using
 templates.

 Where can I find guidance or tutorials on how to do all of this,
 starting with only a rudimentary knowledge of HTML and PHP. It would be
 best if they also focused on procedural rather than object oriented
 code.

 Bob McConnell


When I started learning smarty, I spent most of my time doing research
and that's really tiresome and it is so hard to find examples.
Experimented a lot and listed those what's possible, then applied them
to my projects.

Now to make them handy I posted them to my site so i can have a look
whenever and wherever.
http://www.jampmark.com/php-programming/16-very-useful-smarty-scripting-tips-and-techniques-to-make-templates-smarter.html

As a first step, maybe you should see the crash course at smarty
http://www.smarty.net/crashcourse.php

Virgil
http://www.jampmark.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Smarty Tips and Techniques

2009-03-19 Thread Bob McConnell
From: Virgilio Quilario
 That looks nice, but how do I get to the point where I can understand
 how to use it?

 I have also looked at the Smarty site http://www.smarty.net/, but
 their documents assume significant experience in building and using
 templates.

 Where can I find guidance or tutorials on how to do all of this,
 starting with only a rudimentary knowledge of HTML and PHP. It would
be
 best if they also focused on procedural rather than object oriented
 code.
 
 
 When I started learning smarty, I spent most of my time doing research
 and that's really tiresome and it is so hard to find examples.
 Experimented a lot and listed those what's possible, then applied them
 to my projects.
 
 Now to make them handy I posted them to my site so i can have a look
 whenever and wherever.

http://www.jampmark.com/php-programming/16-very-useful-smarty-scripting-
tips-and-techniques-to-make-templates-smarter.html
 
 As a first step, maybe you should see the crash course at smarty
 http://www.smarty.net/crashcourse.php

Hi Virgil,

After your last post here, I looked at your site, then the Smarty site.
That was what triggered this question. Templates are a black art to me.
I don't even know where to begin to understand them. Every reference I
have looked at so far assumes that I already understand the MVC pattern,
which is also one of the dark arts.

Let me put it simply. I can't grok OO. I tried to do OOP for several
years, but it simply does not make any sense to me. As a direct result,
I don't understand the concept nor application of patterns. So how do I
figure out how to use templates without having to absorb those first?
Can I learn enough this way to determine if a site can be converted from
the current state (PHP and XHTML spaghetti) into templates and begin
that transformation?

Thank you,

Bob McConnell

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Smarty Tips and Techniques

2009-03-19 Thread Bastien Koert
On Thu, Mar 19, 2009 at 11:06 AM, Bob McConnell r...@cbord.com wrote:

 From: Virgilio Quilario
  That looks nice, but how do I get to the point where I can understand
  how to use it?
 
  I have also looked at the Smarty site http://www.smarty.net/, but
  their documents assume significant experience in building and using
  templates.
 
  Where can I find guidance or tutorials on how to do all of this,
  starting with only a rudimentary knowledge of HTML and PHP. It would
 be
  best if they also focused on procedural rather than object oriented
  code.
 
 
  When I started learning smarty, I spent most of my time doing research
  and that's really tiresome and it is so hard to find examples.
  Experimented a lot and listed those what's possible, then applied them
  to my projects.
 
  Now to make them handy I posted them to my site so i can have a look
  whenever and wherever.
 
 http://www.jampmark.com/php-programming/16-very-useful-smarty-scripting-
 tips-and-techniques-to-make-templates-smarter.html
 
  As a first step, maybe you should see the crash course at smarty
  http://www.smarty.net/crashcourse.php

 Hi Virgil,

 After your last post here, I looked at your site, then the Smarty site.
 That was what triggered this question. Templates are a black art to me.
 I don't even know where to begin to understand them. Every reference I
 have looked at so far assumes that I already understand the MVC pattern,
 which is also one of the dark arts.

 Let me put it simply. I can't grok OO. I tried to do OOP for several
 years, but it simply does not make any sense to me. As a direct result,
 I don't understand the concept nor application of patterns. So how do I
 figure out how to use templates without having to absorb those first?
 Can I learn enough this way to determine if a site can be converted from
 the current state (PHP and XHTML spaghetti) into templates and begin
 that transformation?

 Thank you,

 Bob McConnell

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php


Bob,

You really would need to learn those concepts first OOP / MVC. There is a
learning curve, but you really don't need OOP to be able to do an MVC style
application, but it does make the code neater.

One of the books that really helped me grok OOP is Head First OOP...another
is Martin Fowlers Patterns of Enterprise Architecture.

The MVC pattern is explained well in a number of places, but worth checking
out are both the cakephp framework site and the codeingniter site.

You'll find that there are people from both camps here, pure OOP and other
just as happy with procedural coding styles. Many use both, using objects to
handle common tasks like DB interaction or filesystem processes.

-- 

Bastien

Cat, the other other white meat


RE: [PHP] Smarty Tips and Techniques

2009-03-19 Thread Marc Christopher Hall
The following comment is not intended to be helpful

*smacks head on desk repeatedly...*


This comment is..

I would hazard to say that if you are unwilling or unable to grasp OOP, MVCs
and any decent framework that is necessary then maybe stepping back and
tackling only things you can grasp. I do not mean to come across
condescending and I apologize if I have anyway; however, I do not see an
alternative solution for you. Stick to what you are comfortable with and
think about outsourcing the OOP to someone you can trust to write decent
code.





-Original Message-
From: Bob McConnell [mailto:r...@cbord.com] 
Sent: Thursday, March 19, 2009 11:06 AM
To: Virgilio Quilario
Cc: php-general@lists.php.net
Subject: RE: [PHP] Smarty Tips and Techniques

From: Virgilio Quilario
 That looks nice, but how do I get to the point where I can understand
 how to use it?

 I have also looked at the Smarty site http://www.smarty.net/, but
 their documents assume significant experience in building and using
 templates.

 Where can I find guidance or tutorials on how to do all of this,
 starting with only a rudimentary knowledge of HTML and PHP. It would
be
 best if they also focused on procedural rather than object oriented
 code.
 
 
 When I started learning smarty, I spent most of my time doing research
 and that's really tiresome and it is so hard to find examples.
 Experimented a lot and listed those what's possible, then applied them
 to my projects.
 
 Now to make them handy I posted them to my site so i can have a look
 whenever and wherever.

http://www.jampmark.com/php-programming/16-very-useful-smarty-scripting-
tips-and-techniques-to-make-templates-smarter.html
 
 As a first step, maybe you should see the crash course at smarty
 http://www.smarty.net/crashcourse.php

Hi Virgil,

After your last post here, I looked at your site, then the Smarty site.
That was what triggered this question. Templates are a black art to me.
I don't even know where to begin to understand them. Every reference I
have looked at so far assumes that I already understand the MVC pattern,
which is also one of the dark arts.

Let me put it simply. I can't grok OO. I tried to do OOP for several
years, but it simply does not make any sense to me. As a direct result,
I don't understand the concept nor application of patterns. So how do I
figure out how to use templates without having to absorb those first?
Can I learn enough this way to determine if a site can be converted from
the current state (PHP and XHTML spaghetti) into templates and begin
that transformation?

Thank you,

Bob McConnell

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


__ Information from ESET Smart Security, version of virus signature
database 3948 (20090319) __

The message was checked by ESET Smart Security.

http://www.eset.com


 

__ Information from ESET Smart Security, version of virus signature
database 3948 (20090319) __

The message was checked by ESET Smart Security.

http://www.eset.com
 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Smarty Tips and Techniques

2009-03-19 Thread Bob McConnell
From: Bastien Koert
 On Thu, Mar 19, 2009 at 11:06 AM, Bob McConnell r...@cbord.com wrote:
 
   From: Virgilio Quilario
That looks nice, but how do I get to the point where I can
understand
how to use it?
   
I have also looked at the Smarty site
http://www.smarty.net/, but
their documents assume significant experience in building and
using
templates.
   
Where can I find guidance or tutorials on how to do all of
this,
starting with only a rudimentary knowledge of HTML and PHP.
It would
   be
best if they also focused on procedural rather than object
oriented
code.
   
   
When I started learning smarty, I spent most of my time doing
research
and that's really tiresome and it is so hard to find examples.
Experimented a lot and listed those what's possible, then
applied them
to my projects.
   
Now to make them handy I posted them to my site so i can have
a look
whenever and wherever.
   

http://www.jampmark.com/php-programming/16-very-useful-smarty-scripting-
   tips-and-techniques-to-make-templates-smarter.html
http://www.jampmark.com/php-programming/16-very-useful-smarty-scripting
-tips-and-techniques-to-make-templates-smarter.html 
   
As a first step, maybe you should see the crash course at
smarty
http://www.smarty.net/crashcourse.php
   
   Hi Virgil,
   
   After your last post here, I looked at your site, then the
Smarty site.
   That was what triggered this question. Templates are a black art
to me.
   I don't even know where to begin to understand them. Every
reference I
   have looked at so far assumes that I already understand the MVC
pattern,
   which is also one of the dark arts.
   
   Let me put it simply. I can't grok OO. I tried to do OOP for
several
   years, but it simply does not make any sense to me. As a direct
result,
   I don't understand the concept nor application of patterns. So
how do I
   figure out how to use templates without having to absorb those
first?
   Can I learn enough this way to determine if a site can be
converted from
   the current state (PHP and XHTML spaghetti) into templates and
begin
   that transformation?
 
 Bob,
  
 You really would need to learn those concepts first OOP / MVC. There
is
  a learning curve, but you really don't need OOP to be able to do an
MVC
  style application, but it does make the code neater. 
  
 One of the books that really helped me grok OOP is Head First
OOP...another
 is Martin Fowlers Patterns of Enterprise Architecture. 
 
 The MVC pattern is explained well in a number of places, but worth
  checking out are both the cakephp framework site and the codeingniter
site.
  
 You'll find that there are people from both camps here, pure OOP and
other
 just as happy with procedural coding styles. Many use both, using
objects
 to handle common tasks like DB interaction or filesystem processes.

Yes, I have to deal with both camps here as well. Of five developers
doing PHP at the moment, two are primarily using OOP. But I spent 3.5
years as part of a team developing MS-Windows services in C++. After all
that time, I was only able to write basic functions for others to
convert into methods or classes. I could eventually find my way around
in some of those classes, but it seemed that every time I figured out
what was where, somebody refactored a major component and I had to
start all over again. All I saw was a lot of unnecessary overhead and
obfuscation which made little sense in the long run and slowed down both
the development and the application. The result was a handful of DLLs
that are shared between several products, and each time anything is
changed in one of them, every product needs to be retested to make sure
nothing got broke and some have to be recertified for PCI-DSS as well.

So you are telling me that I can forget about trying to use templates.
Since I can not understand OOP, there is no chance I will be able to use
them.

Just knowing that will probably save me several weeks of frustration.

Thank you,

Bob McConnell

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Smarty Tips and Techniques

2009-03-19 Thread Bob McConnell
From: Shawn McKenzie
 Bob McConnell wrote:
 From: Virgilio Quilario
 That looks nice, but how do I get to the point where I can
understand
 how to use it?

 I have also looked at the Smarty site http://www.smarty.net/, but
 their documents assume significant experience in building and using
 templates.

 Where can I find guidance or tutorials on how to do all of this,
 starting with only a rudimentary knowledge of HTML and PHP. It
would
 be
 best if they also focused on procedural rather than object oriented
 code.

 When I started learning smarty, I spent most of my time doing
research
 and that's really tiresome and it is so hard to find examples.
 Experimented a lot and listed those what's possible, then applied
them
 to my projects.

 Now to make them handy I posted them to my site so i can have a look
 whenever and wherever.


http://www.jampmark.com/php-programming/16-very-useful-smarty-scripting-
 tips-and-techniques-to-make-templates-smarter.html
 As a first step, maybe you should see the crash course at smarty
 http://www.smarty.net/crashcourse.php
 
 Hi Virgil,
 
 After your last post here, I looked at your site, then the Smarty
site.
 That was what triggered this question. Templates are a black art to
me.
 I don't even know where to begin to understand them. Every reference
I
 have looked at so far assumes that I already understand the MVC
pattern,
 which is also one of the dark arts.
 
 Let me put it simply. I can't grok OO. I tried to do OOP for several
 years, but it simply does not make any sense to me. As a direct
result,
 I don't understand the concept nor application of patterns. So how do
I
 figure out how to use templates without having to absorb those first?
 Can I learn enough this way to determine if a site can be converted
from
 the current state (PHP and XHTML spaghetti) into templates and begin
 that transformation?
 
 You don't need OOP to use templates.  Smarty is OOP. but there are
some
 lighter faster template solutions, as well as just creating your own
 templates  that you either parse and replace vars in or just use PHP
 code.  As long as you keep the PHP in your templates display oriented
 and not business/app logic based then it should be a nice solution.
 
 You might also look at a framework (codeignitor, cakephp) and go
through
 their tutorial, though these are undoubtedly MVC/OOP, it may make more
 sense once you start building something with it.

Well, I installed CodeIgniter on one of my home servers last night, but
have not yet started through the manual. That will be an interesting
experiment. I am hoping to create a simple recipe management system
there, similar to ReciPants, but in PHP.

At work the problem is more basic; 162 files of interleaved database
access, business logic and presentation, all written by a civil
engineering student with no software training at all. He has moved on,
but five of us working on three products are now dealing with the mess
he left behind.

Thank you,

Bob McConnell

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Smarty Tips and Techniques

2009-03-19 Thread Shawn McKenzie
Bob McConnell wrote:
 From: Virgilio Quilario
 That looks nice, but how do I get to the point where I can understand
 how to use it?

 I have also looked at the Smarty site http://www.smarty.net/, but
 their documents assume significant experience in building and using
 templates.

 Where can I find guidance or tutorials on how to do all of this,
 starting with only a rudimentary knowledge of HTML and PHP. It would
 be
 best if they also focused on procedural rather than object oriented
 code.

 When I started learning smarty, I spent most of my time doing research
 and that's really tiresome and it is so hard to find examples.
 Experimented a lot and listed those what's possible, then applied them
 to my projects.

 Now to make them handy I posted them to my site so i can have a look
 whenever and wherever.

 http://www.jampmark.com/php-programming/16-very-useful-smarty-scripting-
 tips-and-techniques-to-make-templates-smarter.html
 As a first step, maybe you should see the crash course at smarty
 http://www.smarty.net/crashcourse.php
 
 Hi Virgil,
 
 After your last post here, I looked at your site, then the Smarty site.
 That was what triggered this question. Templates are a black art to me.
 I don't even know where to begin to understand them. Every reference I
 have looked at so far assumes that I already understand the MVC pattern,
 which is also one of the dark arts.
 
 Let me put it simply. I can't grok OO. I tried to do OOP for several
 years, but it simply does not make any sense to me. As a direct result,
 I don't understand the concept nor application of patterns. So how do I
 figure out how to use templates without having to absorb those first?
 Can I learn enough this way to determine if a site can be converted from
 the current state (PHP and XHTML spaghetti) into templates and begin
 that transformation?
 
 Thank you,
 
 Bob McConnell

You don't need OOP to use templates.  Smarty is OOP. but there are some
lighter faster template solutions, as well as just creating your own
templates  that you either parse and replace vars in or just use PHP
code.  As long as you keep the PHP in your templates display oriented
and not business/app logic based then it should be a nice solution.

You might also look at a framework (codeignitor, cakephp) and go through
their tutorial, though these are undoubtedly MVC/OOP, it may make more
sense once you start building something with it.

-- 
Thanks!
-Shawn
http://www.spidean.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Smarty Tips and Techniques

2009-03-19 Thread Robert Cummings
On Thu, 2009-03-19 at 12:14 -0400, Bob McConnell wrote:
 From: Bastien Koert
  On Thu, Mar 19, 2009 at 11:06 AM, Bob McConnell r...@cbord.com wrote:
  
  From: Virgilio Quilario
   That looks nice, but how do I get to the point where I can
 understand
   how to use it?
  
   I have also looked at the Smarty site
 http://www.smarty.net/, but
   their documents assume significant experience in building and
 using
   templates.
  
   Where can I find guidance or tutorials on how to do all of
 this,
   starting with only a rudimentary knowledge of HTML and PHP.
 It would
  be
   best if they also focused on procedural rather than object
 oriented
   code.
  
  
   When I started learning smarty, I spent most of my time doing
 research
   and that's really tiresome and it is so hard to find examples.
   Experimented a lot and listed those what's possible, then
 applied them
   to my projects.
  
   Now to make them handy I posted them to my site so i can have
 a look
   whenever and wherever.
  
 
 http://www.jampmark.com/php-programming/16-very-useful-smarty-scripting-
  tips-and-techniques-to-make-templates-smarter.html
 http://www.jampmark.com/php-programming/16-very-useful-smarty-scripting
 -tips-and-techniques-to-make-templates-smarter.html 
  
   As a first step, maybe you should see the crash course at
 smarty
   http://www.smarty.net/crashcourse.php
  
  Hi Virgil,
  
  After your last post here, I looked at your site, then the
 Smarty site.
  That was what triggered this question. Templates are a black art
 to me.
  I don't even know where to begin to understand them. Every
 reference I
  have looked at so far assumes that I already understand the MVC
 pattern,
  which is also one of the dark arts.
  
  Let me put it simply. I can't grok OO. I tried to do OOP for
 several
  years, but it simply does not make any sense to me. As a direct
 result,
  I don't understand the concept nor application of patterns. So
 how do I
  figure out how to use templates without having to absorb those
 first?
  Can I learn enough this way to determine if a site can be
 converted from
  the current state (PHP and XHTML spaghetti) into templates and
 begin
  that transformation?
  
  Bob,
   
  You really would need to learn those concepts first OOP / MVC. There
 is
   a learning curve, but you really don't need OOP to be able to do an
 MVC
   style application, but it does make the code neater. 
   
  One of the books that really helped me grok OOP is Head First
 OOP...another
  is Martin Fowlers Patterns of Enterprise Architecture. 
  
  The MVC pattern is explained well in a number of places, but worth
   checking out are both the cakephp framework site and the codeingniter
 site.
   
  You'll find that there are people from both camps here, pure OOP and
 other
  just as happy with procedural coding styles. Many use both, using
 objects
  to handle common tasks like DB interaction or filesystem processes.
 
 Yes, I have to deal with both camps here as well. Of five developers
 doing PHP at the moment, two are primarily using OOP. But I spent 3.5
 years as part of a team developing MS-Windows services in C++. After all
 that time, I was only able to write basic functions for others to
 convert into methods or classes. I could eventually find my way around
 in some of those classes, but it seemed that every time I figured out
 what was where, somebody refactored a major component and I had to
 start all over again. All I saw was a lot of unnecessary overhead and
 obfuscation which made little sense in the long run and slowed down both
 the development and the application. The result was a handful of DLLs
 that are shared between several products, and each time anything is
 changed in one of them, every product needs to be retested to make sure
 nothing got broke and some have to be recertified for PCI-DSS as well.
 
 So you are telling me that I can forget about trying to use templates.
 Since I can not understand OOP, there is no chance I will be able to use
 them.
 
 Just knowing that will probably save me several weeks of frustration.

OOP for those having trouble:

?php

// Procedural:

function person_get_from_db( $personId )
{
// Load person data based on $personId
}

function person_get_name( $personData )
{
return $personData['name'];
}

function person_set_name( $personData, $name )
{
$personData['name'] = $name;
}

$person = person_get_from_db( 1234 );
person_set_name( $person, 'Bob' );
echo person_get_name( $person );

?

?php

// OOP

class DbPerson
{
private $name;
private $otherPersonData; // ...

function DbPerson( $id )
{
// Load person data based on $id
}

function getName()
{
return $this-name;
}

function setName( $name )
{
$this-name = $name;
}
}


Re: [PHP] Smarty Tips and Techniques

2009-03-19 Thread Bastien Koert
On Thu, Mar 19, 2009 at 12:36 PM, Bob McConnell r...@cbord.com wrote:

 From: Shawn McKenzie
   Bob McConnell wrote:
  From: Virgilio Quilario
  That looks nice, but how do I get to the point where I can
 understand
  how to use it?
 
  I have also looked at the Smarty site http://www.smarty.net/, but
  their documents assume significant experience in building and using
  templates.
 
  Where can I find guidance or tutorials on how to do all of this,
  starting with only a rudimentary knowledge of HTML and PHP. It
 would
  be
  best if they also focused on procedural rather than object oriented
  code.
 
  When I started learning smarty, I spent most of my time doing
 research
  and that's really tiresome and it is so hard to find examples.
  Experimented a lot and listed those what's possible, then applied
 them
  to my projects.
 
  Now to make them handy I posted them to my site so i can have a look
  whenever and wherever.
 
 
 http://www.jampmark.com/php-programming/16-very-useful-smarty-scripting-
  tips-and-techniques-to-make-templates-smarter.html
  As a first step, maybe you should see the crash course at smarty
  http://www.smarty.net/crashcourse.php
 
  Hi Virgil,
 
  After your last post here, I looked at your site, then the Smarty
 site.
  That was what triggered this question. Templates are a black art to
 me.
  I don't even know where to begin to understand them. Every reference
 I
  have looked at so far assumes that I already understand the MVC
 pattern,
  which is also one of the dark arts.
 
  Let me put it simply. I can't grok OO. I tried to do OOP for several
  years, but it simply does not make any sense to me. As a direct
 result,
  I don't understand the concept nor application of patterns. So how do
 I
  figure out how to use templates without having to absorb those first?
  Can I learn enough this way to determine if a site can be converted
 from
  the current state (PHP and XHTML spaghetti) into templates and begin
  that transformation?
 
  You don't need OOP to use templates.  Smarty is OOP. but there are
 some
  lighter faster template solutions, as well as just creating your own
  templates  that you either parse and replace vars in or just use PHP
  code.  As long as you keep the PHP in your templates display oriented
  and not business/app logic based then it should be a nice solution.
 
  You might also look at a framework (codeignitor, cakephp) and go
 through
  their tutorial, though these are undoubtedly MVC/OOP, it may make more
  sense once you start building something with it.

 Well, I installed CodeIgniter on one of my home servers last night, but
 have not yet started through the manual. That will be an interesting
 experiment. I am hoping to create a simple recipe management system
 there, similar to ReciPants, but in PHP.

 At work the problem is more basic; 162 files of interleaved database
 access, business logic and presentation, all written by a civil
 engineering student with no software training at all. He has moved on,
 but five of us working on three products are now dealing with the mess
 he left behind.

 Thank you,

 Bob McConnell

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php



Just 162 files? I don't mean to sound condescending but if the code is that
much trouble, chuck it out and start over. Build it properly by separating
out the db interaction stuff ( and there are great patterns to use there as
well like Active Record or work with an ORM layer like propel or doctrine ).
Then separate out the presentation layer, and define a transport to that
layer from the business logic layer. I like XML for this, passing it to XSLT
for client side transformations into html. Then the DB passes to the
business layer, which does its stuff and then passes the results to the
presentation layer. And the same in reverse, the presentation layer never
talks to the db layer directly.

Creating that separation should make the whole maintenance issue better.
Parts that need to be shared can be copied across to the other applications
so that each app lives in isolation. If that is not possible, the consider
breaking the shared bits into smaller pieces to limit the exposure to
potential issues when you have to make changes. PCI is a pain in the ass and
the rules that govern that make things very difficult, though I can see why
it all needs to be there.

The application I support (classic ASP) comprises 149 Mb of code in some
1500 + files scattered across some 50+ folders each with their own db access
code. Nightmare isn't the word for it. It uses some 160+ DB tables as well.
Rebuilding it is a task that I am looking forward to and am definitely using
the MVC pattern with OOP to some extent. I am looking at codeigniter as the
framework for this as its is one of the fastest and simplest of the
frameworks to work on

HTH

-- 

Bastien

Cat, the other other white meat


RE: [PHP] Smarty Tips and Techniques

2009-03-19 Thread Bob McConnell
From: Bastien Koert
 Just 162 files? I don't mean to sound condescending but if the code
 is that much trouble, chuck it out and start over.

Not going to happen. There are too many other tasks in the backlog that
are more important and will bring in real money as opposed to just
making the developers' lives easier. In addition, the current
application has already passed the PCI Level 1 audit, has been deployed
and is now handling a thousand transactions per day. If I can slip the
changes in piecemeal with those other tasks, fine, but starting over is
not even an option.

All three products combined are processing more than 10K transactions
per day. That spells success as far as management is concerned. With a
long list of client requested enhancements already assembled, code
maintenance issues are not even open for discussion.

Bob McConnell

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Smarty Tips and Techniques

2009-03-19 Thread Michael A. Peters

Marc Christopher Hall wrote:

The following comment is not intended to be helpful

*smacks head on desk repeatedly...*


This comment is..

I would hazard to say that if you are unwilling or unable to grasp OOP, MVCs
and any decent framework that is necessary then maybe stepping back and
tackling only things you can grasp.


To be honest - one of the problems is that documentation that tries to 
explain these concepts is often severely lacking, using extremely poor 
analogies, and only make sense to people who already have an 
understanding of the concept.


For example -

A car is a good real-world example of MVC. With a car you have two 
views: the interior and the exterior. Both take input from the 
controller: the driver. The brakes, steering wheel and other controls 
represent the model: they take input from the controller (driver) and 
hand them off to the views (interior/exterior) for presentation.


That's from a web page that is suppose to explain MVC.

I bet if you took 50 people who didn't have a clue as to what MVC is - 
maybe 1 or 2 of them would after reading that.


Documentation and howto's, just like code, really need to go through 
real world testing to see if they make sense to people not already 
familiar with the topic.


Unfortunately that rarely happens.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Smarty Tips and Techniques

2009-03-19 Thread Robert Cummings
On Thu, 2009-03-19 at 16:27 -0700, Michael A. Peters wrote:
 Marc Christopher Hall wrote:
  The following comment is not intended to be helpful
  
  *smacks head on desk repeatedly...*
  
  
  This comment is..
  
  I would hazard to say that if you are unwilling or unable to grasp OOP, MVCs
  and any decent framework that is necessary then maybe stepping back and
  tackling only things you can grasp.
 
 To be honest - one of the problems is that documentation that tries to 
 explain these concepts is often severely lacking, using extremely poor 
 analogies, and only make sense to people who already have an 
 understanding of the concept.
 
 For example -
 
 A car is a good real-world example of MVC. With a car you have two 
 views: the interior and the exterior. Both take input from the 
 controller: the driver. The brakes, steering wheel and other controls 
 represent the model: they take input from the controller (driver) and 
 hand them off to the views (interior/exterior) for presentation.
 
 That's from a web page that is suppose to explain MVC.
 
 I bet if you took 50 people who didn't have a clue as to what MVC is - 
 maybe 1 or 2 of them would after reading that.
 
 Documentation and howto's, just like code, really need to go through 
 real world testing to see if they make sense to people not already 
 familiar with the topic.
 
 Unfortunately that rarely happens.

I think you have it back asswards. People need to go through real world
development or innane examples and then someone needs ot tell them where
they went wrong. That's how it worked in university. We got an example
like the one above, then we were expected to apply the principle. Those
who undertood it right away got great marks on their assignment, those
who took a little longer didn't... but if they kept at it... till they
figured it out... they got a good mark on the exam. I don't understand
defeatism. Suck it up! There's a zillion examples on the web. Study
many, learn the generalism.

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Smarty Tips and Techniques

2009-03-19 Thread Michael A. Peters

Robert Cummings wrote:

On Thu, 2009-03-19 at 16:27 -0700, Michael A. Peters wrote:

Marc Christopher Hall wrote:

The following comment is not intended to be helpful

*smacks head on desk repeatedly...*


This comment is..

I would hazard to say that if you are unwilling or unable to grasp OOP, MVCs
and any decent framework that is necessary then maybe stepping back and
tackling only things you can grasp.
To be honest - one of the problems is that documentation that tries to 
explain these concepts is often severely lacking, using extremely poor 
analogies, and only make sense to people who already have an 
understanding of the concept.


For example -

A car is a good real-world example of MVC. With a car you have two 
views: the interior and the exterior. Both take input from the 
controller: the driver. The brakes, steering wheel and other controls 
represent the model: they take input from the controller (driver) and 
hand them off to the views (interior/exterior) for presentation.


That's from a web page that is suppose to explain MVC.

I bet if you took 50 people who didn't have a clue as to what MVC is - 
maybe 1 or 2 of them would after reading that.


Documentation and howto's, just like code, really need to go through 
real world testing to see if they make sense to people not already 
familiar with the topic.


Unfortunately that rarely happens.


I think you have it back asswards. People need to go through real world
development or innane examples and then someone needs ot tell them where
they went wrong. That's how it worked in university. We got an example
like the one above, then we were expected to apply the principle. Those
who undertood it right away got great marks on their assignment, those
who took a little longer didn't... but if they kept at it... till they
figured it out... they got a good mark on the exam. I don't understand
defeatism. Suck it up! There's a zillion examples on the web. Study
many, learn the generalism.


The problem is I can make a car analogy out of any type of programming 
design method.


Most of those who got it right away and got great marks did so NOT 
because of what they learned from the example, but because of what they 
already knew before they signed up for the class.


Thus, when the teacher sees some of his students understanding the 
concept, he becomes smug and arrogant and thinks he did something right 
and those who didn't get it have something wrong with them. The reality 
is he can't teach worth shit and those who understood it did so before 
they took his class, hence he didn't teach them anything.


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Smarty Tips and Techniques

2009-03-19 Thread Robert Cummings
On Thu, 2009-03-19 at 18:05 -0700, Michael A. Peters wrote:
 Robert Cummings wrote:
  On Thu, 2009-03-19 at 16:27 -0700, Michael A. Peters wrote:
  Marc Christopher Hall wrote:
  The following comment is not intended to be helpful
 
  *smacks head on desk repeatedly...*
 
 
  This comment is..
 
  I would hazard to say that if you are unwilling or unable to grasp OOP, 
  MVCs
  and any decent framework that is necessary then maybe stepping back and
  tackling only things you can grasp.
  To be honest - one of the problems is that documentation that tries to 
  explain these concepts is often severely lacking, using extremely poor 
  analogies, and only make sense to people who already have an 
  understanding of the concept.
 
  For example -
 
  A car is a good real-world example of MVC. With a car you have two 
  views: the interior and the exterior. Both take input from the 
  controller: the driver. The brakes, steering wheel and other controls 
  represent the model: they take input from the controller (driver) and 
  hand them off to the views (interior/exterior) for presentation.
 
  That's from a web page that is suppose to explain MVC.
 
  I bet if you took 50 people who didn't have a clue as to what MVC is - 
  maybe 1 or 2 of them would after reading that.
 
  Documentation and howto's, just like code, really need to go through 
  real world testing to see if they make sense to people not already 
  familiar with the topic.
 
  Unfortunately that rarely happens.
  
  I think you have it back asswards. People need to go through real world
  development or innane examples and then someone needs ot tell them where
  they went wrong. That's how it worked in university. We got an example
  like the one above, then we were expected to apply the principle. Those
  who undertood it right away got great marks on their assignment, those
  who took a little longer didn't... but if they kept at it... till they
  figured it out... they got a good mark on the exam. I don't understand
  defeatism. Suck it up! There's a zillion examples on the web. Study
  many, learn the generalism.
 
 The problem is I can make a car analogy out of any type of programming 
 design method.

And some people can make a programming design method out of a car
analogy. Your point? Analogies are learning aids, not magic.

 Most of those who got it right away and got great marks did so NOT 
 because of what they learned from the example, but because of what they 
 already knew before they signed up for the class.

You can't generalize that statement though. Many students don't know it
before they enter the class. And for those that did... they probably
learnt it from a trivial unrealistic example also.

 Thus, when the teacher sees some of his students understanding the 
 concept, he becomes smug and arrogant and thinks he did something right 
 and those who didn't get it have something wrong with them. The reality 
 is he can't teach worth shit and those who understood it did so before 
 they took his class, hence he didn't teach them anything.

Once again, you can't generalize that statement. A bad experience with
one teacher can hardly convey a trait to all teachers.

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Smarty Tips and Techniques

2009-03-19 Thread Michael A. Peters

Robert Cummings wrote:

On Thu, 2009-03-19 at 18:05 -0700, Michael A. Peters wrote:

Robert Cummings wrote:

On Thu, 2009-03-19 at 16:27 -0700, Michael A. Peters wrote:

Marc Christopher Hall wrote:

The following comment is not intended to be helpful

*smacks head on desk repeatedly...*


This comment is..

I would hazard to say that if you are unwilling or unable to grasp OOP, MVCs
and any decent framework that is necessary then maybe stepping back and
tackling only things you can grasp.
To be honest - one of the problems is that documentation that tries to 
explain these concepts is often severely lacking, using extremely poor 
analogies, and only make sense to people who already have an 
understanding of the concept.


For example -

A car is a good real-world example of MVC. With a car you have two 
views: the interior and the exterior. Both take input from the 
controller: the driver. The brakes, steering wheel and other controls 
represent the model: they take input from the controller (driver) and 
hand them off to the views (interior/exterior) for presentation.


That's from a web page that is suppose to explain MVC.

I bet if you took 50 people who didn't have a clue as to what MVC is - 
maybe 1 or 2 of them would after reading that.


Documentation and howto's, just like code, really need to go through 
real world testing to see if they make sense to people not already 
familiar with the topic.


Unfortunately that rarely happens.

I think you have it back asswards. People need to go through real world
development or innane examples and then someone needs ot tell them where
they went wrong. That's how it worked in university. We got an example
like the one above, then we were expected to apply the principle. Those
who undertood it right away got great marks on their assignment, those
who took a little longer didn't... but if they kept at it... till they
figured it out... they got a good mark on the exam. I don't understand
defeatism. Suck it up! There's a zillion examples on the web. Study
many, learn the generalism.
The problem is I can make a car analogy out of any type of programming 
design method.


And some people can make a programming design method out of a car
analogy. Your point? Analogies are learning aids, not magic.

Most of those who got it right away and got great marks did so NOT 
because of what they learned from the example, but because of what they 
already knew before they signed up for the class.


You can't generalize that statement though. Many students don't know it
before they enter the class. And for those that did... they probably
learnt it from a trivial unrealistic example also.

Thus, when the teacher sees some of his students understanding the 
concept, he becomes smug and arrogant and thinks he did something right 
and those who didn't get it have something wrong with them. The reality 
is he can't teach worth shit and those who understood it did so before 
they took his class, hence he didn't teach them anything.


Once again, you can't generalize that statement. A bad experience with
one teacher can hardly convey a trait to all teachers.

Cheers,
Rob.


I'm not talking about a bad experience with a teacher.
I'm talking about the use of vague analogies that can be applied to 
anything and really only get the point across to someone already 
familiar with the concept.


It's a real problem in documentation, partly because the review, if any 
is done prior to publishing, is by someone else who already has at least 
a vague understanding of the concept.


IBM Developer documentation and Apple developer documentation (IMHO) 
tend to be better about this than most, but even with them it still is a 
real problem.


-=-

Speaking of Car Analogies - in my auto shop class way back when, they 
used a horse and buggy analogy to show that front wheel drive was 
better, because horses pull a cart, they don't push it.


I then asked where the power in a horse comes from - it's hind legs or 
it's front legs. The instructor was silent for a minute, then responded 
I never thought about that, but you are absolutely right


That's a serious problem with analogies, they always have serious 
problems that you can only ignore if you already understand the concept 
being portrayed by the analogy, and that's why I personally hate them. 
They seem to be quite popular, however, which is a shame.


Just document what the freakin' thing is - analogies just add confusion.

In the case of front wheel drive, the issue actually is engine location 
- not any horse and buggy crap. With front engines, power is lost down 
the long drive train to the rear wheels.


I bet the automobile concept of the a MVC has flaws just as big. A car 
isn't a MVC, it's a freakin' car, and other than the on-board computer 
that adds complexity and increases repair cost, programming method isn't 
part of the design.


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: 

RE: [PHP] Smarty Tips and Techniques

2009-03-19 Thread Bob McConnell
From: Robert Cummings
On Thu, 2009-03-19 at 12:14 -0400, Bob McConnell wrote:
 From: Bastien Koert
  On Thu, Mar 19, 2009 at 11:06 AM, Bob McConnell r...@cbord.com
wrote:
  
 From: Virgilio Quilario

Most discussion clipped for brevity

 // OOP
 
 class DbFireman extends DbPerson
 {
 private $fireman;
 
 function DbPerson( $id )
 {
 parent::__constructor( $id );
 $this-fireman = load_stuff_for_fireman_from_db();
 }
 
 function getStationId()
 {
 return $this-fireman['stationId'];
 }
 
 function setName( $name )
 {
 $this-fireman['stationId'] = $stationId;
 }
 }
 
 $fireman = new DbFireman( 1234 );
 $fireman-setStationId( 'Bob' );
 echo $fireman-getStationId();
 
 ?
 
 So as you can see they're almost identical except that the OOP version
 of fireman didn't need to redeclare functions. True you could have
 skipped doing that if you just used the person functions, but then you
 may introduce onconsistencies. Additionally, the class version ensures
 that the methods applied are those bleong to the concept of fireman
 whereas passing data structures around can easily get confusing,
 especially if you choose to allow the person functions to be applied
to
 the fireman. Going futher, using OOP let's you do all sorts of generic

Hi Rob,

Unfortunately, you still don't understand the problem I have. While it
takes a while to puzzle out the details, I don't have any trouble
reading, understanding or debugging code like this, even though you
skipped completely over several major components (*). I have even
modified existing methods and made minor adjustments to classes, _once
they have been written_.

What I can't do is take a problem description and turn it into classes
that will actually solve the problem. I can usually turn it into
procedures relatively quickly. I can and have built real-time,
multi-tasking and multi-threaded applications on a variety of kernels
and operating systems with no significant trouble. I have written device
drivers, interrupt service routines, message queues and I/O buffering
routines without spending a lot of time thinking about them.

But defining objects and then figuring out how to create and use them
completely escapes me. My mind simply won't map a problem into objects,
it only sees procedures. Even when I look at classes, they resolve only
as loose groupings of functions and variables, not as unified
components.

If anyone knows how to fix that, please tell me. In the meantime, in my
continuing effort to eschew obfuscation, I will stick with procedural
programming.

Bob McConnell

(*) For example, $this- suggests you have added an array of pointers.
Some are pointers to functions (aka methods) others are pointers to
variables (aka members). But there is no indication where this array
came from, what it means, nor how it affects the code structure. From
experience I know that $this- is not always needed, but the C++ rules
for when it is or isn't are neither clear nor consistent. There are no
declarations nor assignments for it. It simply adds another level of
obfuscated dereferencing that needs to be done in my head to understand
what is going on.

You also failed to explain what new does, or parent::__constructor.
What is the relationship between a class and an object? I get frustrated
because of the extra overhead required to instantiate an object with its
members before they can be referenced, instead of simply being able to
use them at any time from anywhere in my code. Likewise, having to pass
a pointer for one object to another object before the second can call
the first is also counter-intuitive. They're all part of the same
application, why doesn't the compiler take care of those details like it
should?

Obviously, I don't expect answers for these questions, but hopefully
this will give you a better understanding of the greater issues
involved. This is a far cry from the Fortran IV I was taught in college
40 years ago. B.M.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Smarty Tips and Techniques

2009-03-19 Thread Michael A. Peters

Bob McConnell wrote:



But defining objects and then figuring out how to create and use them
completely escapes me. My mind simply won't map a problem into objects,
it only sees procedures. Even when I look at classes, they resolve only
as loose groupings of functions and variables, not as unified
components.

If anyone knows how to fix that, please tell me. In the meantime, in my
continuing effort to eschew obfuscation, I will stick with procedural
programming.


As an experienced programmer, please don't laugh too hard at my 
functions within my class - but maybe this will help you:


http://www.clfsrpm.net/xss/cspfilter_class.phps

Other than little piddly stuff (that is just as easily done as a 
function, first class I wrote.


A simplified example of it's usage -

http://www.clfsrpm.net/xss/index.phps

What it does is operate on a DOMDocument object.

I'm not really that fond of OO programming either, but in this case it 
made more sense to view the document to be filtered as objects (xml 
DOMDocument objects) because it made what the filter does much easier to 
program.


Since I was to be operated on object it made sense (to me anyway) to do 
it as a class instead of procedure functions.


However you will notice that all the class really is - is a bunch of 
variable definitions (some public, some private) and procedural 
functions. It's just that they operate only within the scope of the 
DOMDocument object they are told to operate on.


One thing to note - if a function has the same name as the class, it is 
a constructor and will be run when a new instance of the class is 
initiated and it MUST be a public function (why I don't understand, I'd 
prefer it if I could make it private yet still called when a new 
instance of a class is created).


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Smarty Tips and Techniques

2009-03-19 Thread Bipin Upadhyay

Bob McConnell wrote:

[SNIPPED]



the fireman. Going futher, using OOP let's you do all sorts of generic



Hi Rob,

Unfortunately, you still don't understand the problem I have. While it
takes a while to puzzle out the details, I don't have any trouble
reading, understanding or debugging code like this, even though you
skipped completely over several major components (*). I have even
modified existing methods and made minor adjustments to classes, _once
they have been written_.

What I can't do is take a problem description and turn it into classes
that will actually solve the problem. I can usually turn it into
procedures relatively quickly. I can and have built real-time,
multi-tasking and multi-threaded applications on a variety of kernels
and operating systems with no significant trouble. I have written device
drivers, interrupt service routines, message queues and I/O buffering
routines without spending a lot of time thinking about them.

But defining objects and then figuring out how to create and use them
completely escapes me. My mind simply won't map a problem into objects,
it only sees procedures. Even when I look at classes, they resolve only
as loose groupings of functions and variables, not as unified
components.

If anyone knows how to fix that, please tell me. In the meantime, in my
continuing effort to eschew obfuscation, I will stick with procedural
programming.

Bob McConnell

(*) For example, $this- suggests you have added an array of pointers.
Some are pointers to functions (aka methods) others are pointers to
variables (aka members). But there is no indication where this array
came from, what it means, nor how it affects the code structure. From
experience I know that $this- is not always needed, but the C++ rules
for when it is or isn't are neither clear nor consistent. There are no
declarations nor assignments for it. It simply adds another level of
obfuscated dereferencing that needs to be done in my head to understand
what is going on.

You also failed to explain what new does, or parent::__constructor.
What is the relationship between a class and an object? I get frustrated
because of the extra overhead required to instantiate an object with its
members before they can be referenced, instead of simply being able to
use them at any time from anywhere in my code. Likewise, having to pass
a pointer for one object to another object before the second can call
the first is also counter-intuitive. They're all part of the same
application, why doesn't the compiler take care of those details like it
should?

  

Bob,

One of the best books that can help attain a practical understanding of 
OOP is Head First Java. Please do not be eluded by Java in the title.
I'd sincerely encourage you to borrow Head First Java from someone, 
and then buy Head First Object Oriented Analysis  Design.


You'll find answer to most of the questions raised by you, and in pretty 
interesting ways.

Obviously, I don't expect answers for these questions, but hopefully
this will give you a better understanding of the greater issues
involved. This is a far cry from the Fortran IV I was taught in college
40 years ago. B.M.

  

--
Regards,
Bipin Upadhyay.
http://projectbee.org/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Smarty Tips and Techniques

2009-03-18 Thread Virgilio Quilario
Hi list,

Just wanna share my collection of Smarty scripting tips and techniques.
Smarty is a template engine for PHP that you can use to separate data
and logic from web design.
This way programmers can work on the php scripts and designers can
work on the templates for the same web site.

Here is the link:
http://www.jampmark.com/php-programming/16-very-useful-smarty-scripting-tips-and-techniques-to-make-templates-smarter.html

Hope you find it useful.

Virgil

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Smarty Tips and Techniques

2009-03-18 Thread Bob McConnell
That looks nice, but how do I get to the point where I can understand
how to use it?

I have also looked at the Smarty site http://www.smarty.net/, but
their documents assume significant experience in building and using
templates.

Where can I find guidance or tutorials on how to do all of this,
starting with only a rudimentary knowledge of HTML and PHP. It would be
best if they also focused on procedural rather than object oriented
code.

Bob McConnell

-Original Message-
From: Virgilio Quilario [mailto:virgilio.quila...@gmail.com] 
Sent: Wednesday, March 18, 2009 10:36 AM
To: php-general@lists.php.net
Subject: [PHP] Smarty Tips and Techniques

Hi list,

Just wanna share my collection of Smarty scripting tips and techniques.
Smarty is a template engine for PHP that you can use to separate data
and logic from web design.
This way programmers can work on the php scripts and designers can
work on the templates for the same web site.

Here is the link:
http://www.jampmark.com/php-programming/16-very-useful-smarty-scripting-
tips-and-techniques-to-make-templates-smarter.html

Hope you find it useful.

Virgil

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Smarty Tips and Techniques

2009-03-18 Thread Thodoris



That looks nice, but how do I get to the point where I can understand
how to use it?

I have also looked at the Smarty site http://www.smarty.net/, but
their documents assume significant experience in building and using
templates.

Where can I find guidance or tutorials on how to do all of this,
starting with only a rudimentary knowledge of HTML and PHP. It would be
best if they also focused on procedural rather than object oriented
code.

Bob McConnell

-Original Message-
From: Virgilio Quilario [mailto:virgilio.quila...@gmail.com] 
Sent: Wednesday, March 18, 2009 10:36 AM

To: php-general@lists.php.net
Subject: [PHP] Smarty Tips and Techniques

Hi list,

Just wanna share my collection of Smarty scripting tips and techniques.
Smarty is a template engine for PHP that you can use to separate data
and logic from web design.
This way programmers can work on the php scripts and designers can
work on the templates for the same web site.

Here is the link:
http://www.jampmark.com/php-programming/16-very-useful-smarty-scripting-
tips-and-techniques-to-make-templates-smarter.html

Hope you find it useful.

Virgil

  


I have stared using smarty myself in a recent project I am still making 
and I'll have to say that it has its virtues.


Look at a simple example in the smarty's site and use the manual for any 
questions. You will probably find some stuff by googling.


The templates (simply put) are actually html-like that has some php 
variables inside you may assign before displaying the actual template.

This way you customize the template to output what you need.

Above that you may start using the statements to automatically build 
forms, tables etc


I like the fact that there is a cache and that the templates get 
compiled which make them faster to process.


Nevertheless you need time to get familiar with the smarty way of 
thinking as with all frameworks and template engines you need to use.


--
Thodoris


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] PHP, Smarty, and Text

2009-01-14 Thread Phpster
Only allow a few markup tags, strip_tags() allows a limited lIst to be  
kept



Bastien

Sent from my iPod

On Jan 13, 2009, at 11:18 PM, Daniel Kolbo kolb0...@umn.edu wrote:




Phpster wrote:


What about stripping out all the 'nuances' and just reducing it to  
just the text where you then control the display and using your  
templates and css?


Bastien

Sent from my iPod

On Jan 13, 2009, at 9:49 PM, Daniel Kolbo kolb0...@umn.edu wrote:


Hello,

I've been using PHP and Smarty for several years now and I am  
happy with this division of data from presentation.  With this  
philosophy in mind, i am a bit perplexed as to how to handle the  
text on my sites.  That is, the text is data, so i am motivated to  
store the text in a database, files, or the like, but then text is  
loaded with little markup nuances (random italics/weight/colors,  
etc...) that make template design rather ugly.  This motivates me  
to put markup (maybe even my own brand of markup) around the text,  
and to store this markup-text combination in a database.  But I  
don't like this either, because a lot of the people writing the  
content/text know word/writer not markup.  So i am motivated to  
have them save their text as .html, and I parse this file and  
modify accordingly.  However, i don't like this either as not all  
word/writer styles are 1-to-1 with CSS.  Without any options I am  
back to thinking hard code the text with markup in included  
templates, but it hurts just thinking of updating/modifying.


I have looked (briefly) at Web Content Management Systems, but  
this seems like overkill really, maybe i'm ignorant.


What would the community suggest? The text can take on many forms,  
introduction text, about text, product information, articles,  
blurbs, (some changes daily, some doesn't) etc...where does all  
this text live in 'properly' designed site.


Thanks in advance,
dK




Hello Bastien,
The difficulty with implementing your suggestions is that say in a  
paragraph of text that has random bold or italics (etc...) (as  
determined by the one drafting the text), how would i recover these  
bold/italics if i remove them?

dK


Re: [PHP] PHP, Smarty, and Text

2009-01-14 Thread Daniel Kolbo

Robert Cummings wrote:

On Tue, 2009-01-13 at 18:18 -1000, Daniel Kolbo wrote:
  

Phpster wrote:

What about stripping out all the 'nuances' and just reducing it to 
just the text where you then control the display and using your 
templates and css?


Bastien

Sent from my iPod

On Jan 13, 2009, at 9:49 PM, Daniel Kolbo kolb0...@umn.edu wrote:

  

Hello,

I've been using PHP and Smarty for several years now and I am happy 
with this division of data from presentation.  With this philosophy 
in mind, i am a bit perplexed as to how to handle the text on my 
sites.  That is, the text is data, so i am motivated to store the 
text in a database, files, or the like, but then text is loaded with 
little markup nuances (random italics/weight/colors, etc...) that 
make template design rather ugly.  This motivates me to put markup 
(maybe even my own brand of markup) around the text, and to store 
this markup-text combination in a database.  But I don't like this 
either, because a lot of the people writing the content/text know 
word/writer not markup.  So i am motivated to have them save their 
text as .html, and I parse this file and modify accordingly.  
However, i don't like this either as not all word/writer styles are 
1-to-1 with CSS.  Without any options I am back to thinking hard 
code the text with markup in included templates, but it hurts just 
thinking of updating/modifying.


I have looked (briefly) at Web Content Management Systems, but this 
seems like overkill really, maybe i'm ignorant.


What would the community suggest? The text can take on many forms, 
introduction text, about text, product information, articles, blurbs, 
(some changes daily, some doesn't) etc...where does all this text 
live in 'properly' designed site.


Thanks in advance,
dK



Hello Bastien,
The difficulty with implementing your suggestions is that say in a 
paragraph of text that has random bold or italics (etc...) (as 
determined by the one drafting the text), how would i recover these 
bold/italics if i remove them?



Strip all tags except bold and italics. Then replace b with strong
and i with em since the former tags are deprecated. If semantic
meaning is not intended by b and i then replace with span
class=bold and span class=italic and create those CSS styles.

Cheers,
Rob.
  
Yes, okay, but who is putting the tags there in the first place?  The 
writers who are drafting these in word/writer are not marking them 
up...So say I put tags around the required items, then when the writer 
goes to edit, they are going to say what is all this, it is not a 
'seamless' division.  I am really looking for a three fold division, 1) 
Logic/data, 2) presentation, and 3) text.  Just like the logic side 
doesn't concern itself with presentation, I'd like the writers to not be 
concerned with presentation/markup either (except for using the styles 
available in word/writer).


It seems a bit tricky...the writer is providing the data without PHP 
knowledge and some styles without Smarty knowledge.  The question is how 
does one bridge this strange gap in a manageable and easily scalable way?

dK


Re: [PHP] PHP, Smarty, and Text

2009-01-14 Thread Robert Cummings
On Wed, 2009-01-14 at 09:08 -1000, Daniel Kolbo wrote:
 Robert Cummings wrote:
  On Tue, 2009-01-13 at 18:18 -1000, Daniel Kolbo wrote:

  Phpster wrote:
  
  What about stripping out all the 'nuances' and just reducing it to 
  just the text where you then control the display and using your 
  templates and css?
 
  Bastien
 
  Sent from my iPod
 
  On Jan 13, 2009, at 9:49 PM, Daniel Kolbo kolb0...@umn.edu wrote:
 

  Hello,
 
  I've been using PHP and Smarty for several years now and I am happy 
  with this division of data from presentation.  With this philosophy 
  in mind, i am a bit perplexed as to how to handle the text on my 
  sites.  That is, the text is data, so i am motivated to store the 
  text in a database, files, or the like, but then text is loaded with 
  little markup nuances (random italics/weight/colors, etc...) that 
  make template design rather ugly.  This motivates me to put markup 
  (maybe even my own brand of markup) around the text, and to store 
  this markup-text combination in a database.  But I don't like this 
  either, because a lot of the people writing the content/text know 
  word/writer not markup.  So i am motivated to have them save their 
  text as .html, and I parse this file and modify accordingly.  
  However, i don't like this either as not all word/writer styles are 
  1-to-1 with CSS.  Without any options I am back to thinking hard 
  code the text with markup in included templates, but it hurts just 
  thinking of updating/modifying.
 
  I have looked (briefly) at Web Content Management Systems, but this 
  seems like overkill really, maybe i'm ignorant.
 
  What would the community suggest? The text can take on many forms, 
  introduction text, about text, product information, articles, blurbs, 
  (some changes daily, some doesn't) etc...where does all this text 
  live in 'properly' designed site.
 
  Thanks in advance,
  dK
 
  
  Hello Bastien,
  The difficulty with implementing your suggestions is that say in a 
  paragraph of text that has random bold or italics (etc...) (as 
  determined by the one drafting the text), how would i recover these 
  bold/italics if i remove them?
  
 
  Strip all tags except bold and italics. Then replace b with strong
  and i with em since the former tags are deprecated. If semantic
  meaning is not intended by b and i then replace with span
  class=bold and span class=italic and create those CSS styles.
 
  Cheers,
  Rob.

 Yes, okay, but who is putting the tags there in the first place?  The 
 writers who are drafting these in word/writer are not marking them 
 up...So say I put tags around the required items, then when the writer 
 goes to edit, they are going to say what is all this, it is not a 
 'seamless' division.  I am really looking for a three fold division, 1) 
 Logic/data, 2) presentation, and 3) text.  Just like the logic side 
 doesn't concern itself with presentation, I'd like the writers to not be 
 concerned with presentation/markup either (except for using the styles 
 available in word/writer).
 
 It seems a bit tricky...the writer is providing the data without PHP 
 knowledge and some styles without Smarty knowledge.  The question is how 
 does one bridge this strange gap in a manageable and easily scalable way?

So apply the stripping and replacements to the content you have saved,
but don't modify the saved content itself. You can add another field to
the same table containing the data called formatted_content and save
it alongside the original. The tags are being inserted by Microsoft when
you copy/paste from one medium to another. I do beleive MS detects you
are pasting from a Word document to an HTML format and transparently
performs the conversion for you.

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] PHP, Smarty, and Text

2009-01-14 Thread Edmund Hertle

 Robert Cummings wrote:

 On Tue, 2009-01-13 at 18:18 -1000, Daniel Kolbo wrote:


 Phpster wrote:


 What about stripping out all the 'nuances' and just reducing it to just
 the text where you then control the display and using your templates and
 css?

 Bastien

 Sent from my iPod

 On Jan 13, 2009, at 9:49 PM, Daniel Kolbo kolb0...@umn.edu wrote:



 Hello,

 I've been using PHP and Smarty for several years now and I am happy
 with this division of data from presentation.  With this philosophy in
 mind, i am a bit perplexed as to how to handle the text on my sites.  That
 is, the text is data, so i am motivated to store the text in a database,
 files, or the like, but then text is loaded with little markup nuances
 (random italics/weight/colors, etc...) that make template design rather
 ugly.  This motivates me to put markup (maybe even my own brand of markup)
 around the text, and to store this markup-text combination in a database.
  But I don't like this either, because a lot of the people writing the
 content/text know word/writer not markup.  So i am motivated to have them
 save their text as .html, and I parse this file and modify accordingly.
  However, i don't like this either as not all word/writer styles are 
 1-to-1
 with CSS.  Without any options I am back to thinking hard code the text
 with markup in included templates, but it hurts just thinking of
 updating/modifying.

 I have looked (briefly) at Web Content Management Systems, but this
 seems like overkill really, maybe i'm ignorant.

 What would the community suggest? The text can take on many forms,
 introduction text, about text, product information, articles, blurbs, 
 (some
 changes daily, some doesn't) etc...where does all this text live in
 'properly' designed site.

 Thanks in advance,
 dK



 Hello Bastien,
 The difficulty with implementing your suggestions is that say in a
 paragraph of text that has random bold or italics (etc...) (as determined by
 the one drafting the text), how would i recover these bold/italics if i
 remove them?



 Strip all tags except bold and italics. Then replace b with strong
 and i with em since the former tags are deprecated. If semantic
 meaning is not intended by b and i then replace with span
 class=bold and span class=italic and create those CSS styles.

 Cheers,
 Rob.


 Yes, okay, but who is putting the tags there in the first place?  The
 writers who are drafting these in word/writer are not marking them up...So
 say I put tags around the required items, then when the writer goes to edit,
 they are going to say what is all this, it is not a 'seamless' division.
  I am really looking for a three fold division, 1) Logic/data, 2)
 presentation, and 3) text.  Just like the logic side doesn't concern itself
 with presentation, I'd like the writers to not be concerned with
 presentation/markup either (except for using the styles available in
 word/writer).

 It seems a bit tricky...the writer is providing the data without PHP
 knowledge and some styles without Smarty knowledge.  The question is how
 does one bridge this strange gap in a manageable and easily scalable way?
 dK

What about using a WYSIWYG Editor?
http://tinymce.moxiecode.com/
Data created by the editor can then be parsed to change elements or add
classes (and then should also be parsed back when again editing the data)


Re: [PHP] PHP, Smarty, and Text

2009-01-14 Thread ceo

One way to balance the author's need to have nice-looking output, and your need 
to keep the content/html under control is to provide the authors with a variety 
of template layouts with varying number/placement/sizes of images and blocks of 
text.



Build a half-dozen of them, allow only ASCII text input, let the author pick 
their poison, and Bob's yer uncle, for many clients/projects.



Make them generic enough and re-use them forever. :-)



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] PHP, Smarty, and Text

2009-01-14 Thread VamVan
On Tue, Jan 13, 2009 at 6:49 PM, Daniel Kolbo kolb0...@umn.edu wrote:

 Hello,

 I've been using PHP and Smarty for several years now and I am happy with
 this division of data from presentation.  With this philosophy in mind, i
 am a bit perplexed as to how to handle the text on my sites.  That is, the
 text is data, so i am motivated to store the text in a database, files, or
 the like, but then text is loaded with little markup nuances (random
 italics/weight/colors, etc...) that make template design rather ugly.  This
 motivates me to put markup (maybe even my own brand of markup) around the
 text, and to store this markup-text combination in a database.  But I don't
 like this either, because a lot of the people writing the content/text know
 word/writer not markup.  So i am motivated to have them save their text as
 .html, and I parse this file and modify accordingly.  However, i don't like
 this either as not all word/writer styles are 1-to-1 with CSS.  Without any
 options I am back to thinking hard code the text with markup in included
 templates, but it hurts just thinking of updating/modifying.

 I have looked (briefly) at Web Content Management Systems, but this seems
 like overkill really, maybe i'm ignorant.

 What would the community suggest?  The text can take on many forms,
 introduction text, about text, product information, articles, blurbs, (some
 changes daily, some doesn't) etc...where does all this text live in
 'properly' designed site.

 Thanks in advance,
 dK



For specific requirements like this. I think it is very OK to set some
rules  when the user inputs the text. You can make the simple text area and
make some custom tags for ur application only. For example bold in ur
application means b in html.

This way you can str_replace all that user enters in to watever class or
text u want to to make it look pretty. Its an easier way and reliable way
because you have the authority to validate user input if it does not match
certian criteria that you may need.

I don't know you can never blame user for what he enters. Not every user is
computer literate and our code should always cater the needs of this kind of
user and I feel its perfectly ok to tell the user to enter proper data if it
doesnot meet ur standards.

Thanks,
V


Re: [PHP] PHP, Smarty, and Text

2009-01-14 Thread Nathan Rixham

VamVan wrote:

On Tue, Jan 13, 2009 at 6:49 PM, Daniel Kolbo kolb0...@umn.edu wrote:


Hello,

I've been using PHP and Smarty for several years now and I am happy with
this division of data from presentation.  With this philosophy in mind, i
am a bit perplexed as to how to handle the text on my sites.  That is, the
text is data, so i am motivated to store the text in a database, files, or
the like, but then text is loaded with little markup nuances (random
italics/weight/colors, etc...) that make template design rather ugly.  This
motivates me to put markup (maybe even my own brand of markup) around the
text, and to store this markup-text combination in a database.  But I don't
like this either, because a lot of the people writing the content/text know
word/writer not markup.  So i am motivated to have them save their text as
.html, and I parse this file and modify accordingly.  However, i don't like
this either as not all word/writer styles are 1-to-1 with CSS.  Without any
options I am back to thinking hard code the text with markup in included
templates, but it hurts just thinking of updating/modifying.

I have looked (briefly) at Web Content Management Systems, but this seems
like overkill really, maybe i'm ignorant.

What would the community suggest?  The text can take on many forms,
introduction text, about text, product information, articles, blurbs, (some
changes daily, some doesn't) etc...where does all this text live in
'properly' designed site.

Thanks in advance,
dK




For specific requirements like this. I think it is very OK to set some
rules  when the user inputs the text. You can make the simple text area and
make some custom tags for ur application only. For example bold in ur
application means b in html.

This way you can str_replace all that user enters in to watever class or
text u want to to make it look pretty. Its an easier way and reliable way
because you have the authority to validate user input if it does not match
certian criteria that you may need.

I don't know you can never blame user for what he enters. Not every user is
computer literate and our code should always cater the needs of this kind of
user and I feel its perfectly ok to tell the user to enter proper data if it
doesnot meet ur standards.

Thanks,
V



perhaps you need to make a high level internal decision in you're own 
brain.. decide if the text is in fact text, or is it fragments of html 
- decide which it is then treat it accordingly - if you decide it's html 
then all you need to do is sanitize it and save it wherever (database, 
flat files, anything); - note: i often think it's wise to save a plain 
text version of all html fragments in addition, saves you repeating code 
and is smaller if you want to save it in a fulltext indexed column (more 
space in the db sicne two versions, but faster better indexes as only on 
the plaintext)


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] PHP, Smarty, and Text

2009-01-14 Thread Benjamin Hawkes-Lewis

On 14/1/09 07:56, Robert Cummings wrote:

Strip all tags except bold and italics. Then replaceb  withstrong
andi  withem  since the former tags are deprecated.


Actually, b and i have not been formally deprecated in any standard.

The closest thing to a prohibition on these elements is WCAG 1.0's 
Checkpoint 3.3 Use style sheets to control layout and presentation.



If semantic meaning is not intended byb  andi then replace
withspan class=bold  andspan class=italic  and create those
CSS styles.


em is for stress.

strong is for strong stress.

In the third case, where semantic meaning _is_ intended by bold or 
italic but that meaning is _not_ stress, it's best to use relevant 
specific elements (code, var, cite, q, kbd, samp, etc.?) or 
failing that class names that express meaning not just style ( 
http://www.w3.org/QA/Tips/goodclassnames ).


--
Benjamin Hawkes-Lewis

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] PHP, Smarty, and Text

2009-01-13 Thread Daniel Kolbo

Hello,

I've been using PHP and Smarty for several years now and I am happy with 
this division of data from presentation.  With this philosophy in 
mind, i am a bit perplexed as to how to handle the text on my sites.  
That is, the text is data, so i am motivated to store the text in a 
database, files, or the like, but then text is loaded with little markup 
nuances (random italics/weight/colors, etc...) that make template design 
rather ugly.  This motivates me to put markup (maybe even my own brand 
of markup) around the text, and to store this markup-text combination in 
a database.  But I don't like this either, because a lot of the people 
writing the content/text know word/writer not markup.  So i am motivated 
to have them save their text as .html, and I parse this file and modify 
accordingly.  However, i don't like this either as not all word/writer 
styles are 1-to-1 with CSS.  Without any options I am back to thinking 
hard code the text with markup in included templates, but it hurts 
just thinking of updating/modifying.


I have looked (briefly) at Web Content Management Systems, but this 
seems like overkill really, maybe i'm ignorant.


What would the community suggest?  The text can take on many forms, 
introduction text, about text, product information, articles, blurbs, 
(some changes daily, some doesn't) etc...where does all this text live 
in 'properly' designed site.


Thanks in advance,
dK



Re: [PHP] PHP, Smarty, and Text

2009-01-13 Thread Phpster
What about stripping out all the 'nuances' and just reducing it to  
just the text where you then control the display and using your  
templates and css?


Bastien

Sent from my iPod

On Jan 13, 2009, at 9:49 PM, Daniel Kolbo kolb0...@umn.edu wrote:


Hello,

I've been using PHP and Smarty for several years now and I am happy  
with this division of data from presentation.  With this  
philosophy in mind, i am a bit perplexed as to how to handle the  
text on my sites.  That is, the text is data, so i am motivated to  
store the text in a database, files, or the like, but then text is  
loaded with little markup nuances (random italics/weight/colors,  
etc...) that make template design rather ugly.  This motivates me to  
put markup (maybe even my own brand of markup) around the text, and  
to store this markup-text combination in a database.  But I don't  
like this either, because a lot of the people writing the content/ 
text know word/writer not markup.  So i am motivated to have them  
save their text as .html, and I parse this file and modify  
accordingly.  However, i don't like this either as not all word/ 
writer styles are 1-to-1 with CSS.  Without any options I am back to  
thinking hard code the text with markup in included templates, but  
it hurts just thinking of updating/modifying.


I have looked (briefly) at Web Content Management Systems, but this  
seems like overkill really, maybe i'm ignorant.


What would the community suggest? The text can take on many forms,  
introduction text, about text, product information, articles,  
blurbs, (some changes daily, some doesn't) etc...where does all this  
text live in 'properly' designed site.


Thanks in advance,
dK



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] PHP, Smarty, and Text

2009-01-13 Thread Daniel Kolbo



Phpster wrote:
What about stripping out all the 'nuances' and just reducing it to 
just the text where you then control the display and using your 
templates and css?


Bastien

Sent from my iPod

On Jan 13, 2009, at 9:49 PM, Daniel Kolbo kolb0...@umn.edu wrote:


Hello,

I've been using PHP and Smarty for several years now and I am happy 
with this division of data from presentation.  With this philosophy 
in mind, i am a bit perplexed as to how to handle the text on my 
sites.  That is, the text is data, so i am motivated to store the 
text in a database, files, or the like, but then text is loaded with 
little markup nuances (random italics/weight/colors, etc...) that 
make template design rather ugly.  This motivates me to put markup 
(maybe even my own brand of markup) around the text, and to store 
this markup-text combination in a database.  But I don't like this 
either, because a lot of the people writing the content/text know 
word/writer not markup.  So i am motivated to have them save their 
text as .html, and I parse this file and modify accordingly.  
However, i don't like this either as not all word/writer styles are 
1-to-1 with CSS.  Without any options I am back to thinking hard 
code the text with markup in included templates, but it hurts just 
thinking of updating/modifying.


I have looked (briefly) at Web Content Management Systems, but this 
seems like overkill really, maybe i'm ignorant.


What would the community suggest? The text can take on many forms, 
introduction text, about text, product information, articles, blurbs, 
(some changes daily, some doesn't) etc...where does all this text 
live in 'properly' designed site.


Thanks in advance,
dK


Hello Bastien,
The difficulty with implementing your suggestions is that say in a 
paragraph of text that has random bold or italics (etc...) (as 
determined by the one drafting the text), how would i recover these 
bold/italics if i remove them?

dK


Re: [PHP] PHP, Smarty, and Text

2009-01-13 Thread Robert Cummings
On Tue, 2009-01-13 at 18:18 -1000, Daniel Kolbo wrote:
 
 Phpster wrote:
  What about stripping out all the 'nuances' and just reducing it to 
  just the text where you then control the display and using your 
  templates and css?
 
  Bastien
 
  Sent from my iPod
 
  On Jan 13, 2009, at 9:49 PM, Daniel Kolbo kolb0...@umn.edu wrote:
 
  Hello,
 
  I've been using PHP and Smarty for several years now and I am happy 
  with this division of data from presentation.  With this philosophy 
  in mind, i am a bit perplexed as to how to handle the text on my 
  sites.  That is, the text is data, so i am motivated to store the 
  text in a database, files, or the like, but then text is loaded with 
  little markup nuances (random italics/weight/colors, etc...) that 
  make template design rather ugly.  This motivates me to put markup 
  (maybe even my own brand of markup) around the text, and to store 
  this markup-text combination in a database.  But I don't like this 
  either, because a lot of the people writing the content/text know 
  word/writer not markup.  So i am motivated to have them save their 
  text as .html, and I parse this file and modify accordingly.  
  However, i don't like this either as not all word/writer styles are 
  1-to-1 with CSS.  Without any options I am back to thinking hard 
  code the text with markup in included templates, but it hurts just 
  thinking of updating/modifying.
 
  I have looked (briefly) at Web Content Management Systems, but this 
  seems like overkill really, maybe i'm ignorant.
 
  What would the community suggest? The text can take on many forms, 
  introduction text, about text, product information, articles, blurbs, 
  (some changes daily, some doesn't) etc...where does all this text 
  live in 'properly' designed site.
 
  Thanks in advance,
  dK
 
 Hello Bastien,
 The difficulty with implementing your suggestions is that say in a 
 paragraph of text that has random bold or italics (etc...) (as 
 determined by the one drafting the text), how would i recover these 
 bold/italics if i remove them?

Strip all tags except bold and italics. Then replace b with strong
and i with em since the former tags are deprecated. If semantic
meaning is not intended by b and i then replace with span
class=bold and span class=italic and create those CSS styles.

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Smarty Question

2007-10-01 Thread Stut

Shahrzad wrote:

IRIran.netHi,
I want to replace a php variable with a javascript variable inside script 
type=text/javascript tag in a TPL file(smarty) , how can I do that?

//what in my mind is  , but this code is wrong
///
 var Country = document.search.country;
 {php} $me={/php} Country.value  {php};{/php}
//

Thanks 


Smarty have their own mailing lists - please use them.

-Stut

--
http://stut.net/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Smarty template for parent-child form

2007-07-24 Thread Man-wai Chang

Is there a template that presents a parent-child
forms, for example, an invoice object which has a header(invoice no,
date, customer code, invoice total) and multiple items (item no, item
name, quantity, price, amount)?


-- 
  @~@   Might, Courage, Vision, SINCERITY.
 / v \  Simplicity is Beauty! May the Force and Farce be with you!
/( _ )\ (Xubuntu 7.04)  Linux 2.6.22.1
  ^ ^   19:12:01 up 12 days 21:16 1 user load average: 0.06 0.06 0.02
news://news.3home.net news://news.hkpcug.org news://news.newsgroup.com.hk

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Smarty template for parent-child form

2007-07-24 Thread Chad Robinson
Man-wai Chang wrote:
 Is there a template that presents a parent-child
 forms, for example, an invoice object which has a header(invoice no,
 date, customer code, invoice total) and multiple items (item no, item
 name, quantity, price, amount)?
   
Go to http://smarty.php.net/manual/en/language.function.foreach.php

What you do is assign the items to an array called, say, items. Then you
use foreach in the template to iterate the array, just like you would
in PHP itself. Example 7-8 (Contacts) is pretty close to what you're doing.

Regards,
Chad

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Smarty Website down?

2007-03-27 Thread Mario Guenterberg
Hi...

I try to connect in the last hours and the results are timeouts.

Greetings
Mario

-- 
 -
| havelsoft.com - Ihr Service Partner für Open Source |
| Tel:  033876-21 966 |
| Notruf: 0173-277 33 60  |
| http://www.havelsoft.com|
| |
| Inhaber: Mario Günterberg   |
| Mützlitzer Strasse 19   |
| 14715 Märkisch Luch |
 -

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Smarty Website down?

2007-03-27 Thread Martin Marques

On Tue, 27 Mar 2007, Mario Guenterberg wrote:


Hi...

I try to connect in the last hours and the results are timeouts.


Excelent connection here.

--
 21:50:04 up 2 days,  9:07,  0 users,  load average: 0.92, 0.37, 0.18
-
Lic. Martín Marqués |   SELECT 'mmarques' ||
Centro de Telemática|   '@' || 'unl.edu.ar';
Universidad Nacional|   DBA, Programador,
del Litoral |   Administrador
-
-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[PHP] [Smarty]How smarty name its combiled file?

2006-11-23 Thread John . H

It just like %%58^588^588C8934%%second.html.php.
How does this filename be created?


RE: [PHP] [Smarty]How smarty name its combiled file?

2006-11-23 Thread Edward Kay
How about sending this to the Smarty list?
http://smarty.php.net/resources.php?category=7

Edward

 -Original Message-
 From: John.H [mailto:[EMAIL PROTECTED]
 Sent: 23 November 2006 11:55
 To: php-general
 Subject: [PHP] [Smarty]How smarty name its combiled file?
 
 
 It just like %%58^588^588C8934%%second.html.php.
 How does this filename be created?
 
 

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Smarty error

2006-05-05 Thread Nirmalya Lahiri
Dear all,
  I wrote this script using Smarty template,which gives a syntax error ..
 
 syntax error: unrecognized tag:  (Smarty_Compiler.class.php, line 436)
 
 
 I wrote a javascript block in template file,where I use '{'. This '{' 
acctually shows the problem. How can I solve this problem?
 
 --Nirmalya Lahiri
 

-
Yahoo! Messenger with Voice. Make PC-to-Phone Calls to the US (and 30+ 
countries) for 2¢/min or less.

Re: [PHP] Smarty error

2006-05-05 Thread Nirmalya Lahiri
Dear all,
  I solved the problem using {literal}{/literal} tag. Thanks every one, who 
gives me tips to solve the error.
 
 --Nirmalya
 

Nirmalya Lahiri [EMAIL PROTECTED] wrote: Dear all,
  I wrote this script using Smarty template,which gives a syntax error ..
 
 syntax error: unrecognized tag:  (Smarty_Compiler.class.php, line 436)
 
 
 I wrote a javascript block in template file,where I use '{'. This '{' 
acctually shows the problem. How can I solve this problem?
 
 --Nirmalya Lahiri
 
  
-
Yahoo! Messenger with Voice. Make PC-to-Phone Calls to the US (and 30+ 
countries) for 2¢/min or less.


-
New Yahoo! Messenger with Voice. Call regular phones from your PC and save big.

Re: [PHP] Smarty error

2006-05-05 Thread John Nichel

Nirmalya Lahiri wrote:

Dear all,
  I wrote this script using Smarty template,which gives a syntax error ..
 
 syntax error: unrecognized tag:  (Smarty_Compiler.class.php, line 436)
 
 
 I wrote a javascript block in template file,where I use '{'. This '{' acctually shows the problem. How can I solve this problem?




http://smarty.php.net/resources.php?category=7

--
John C. Nichel IV
Programmer/System Admin (ÜberGeek)
Dot Com Holdings of Buffalo
716.856.9675
[EMAIL PROTECTED]

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Smarty Templates?

2006-02-08 Thread R. Van Tassel
I'm contemplating using Smarty Templates for a website and was wondering
what opinions on them, pro or con, may be.

Thanks in advance for all your help.

-Roy

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Smarty Templates?

2006-02-08 Thread Jochem Maas

starting a new topic by replying to an existing thread is
bad form - we know how much work it is to click on the 'new mail'
button and fill in an address but please make the effort (it's in your
interest as well!).

with regard to Smarty why not try searching for existing writing on the subject?

e.g. http://www.google.com/search?q=pros+and+cons+of+Smarty+template+engine

as to opinion :: the only one that counts is yours - just make sure
you take the time to form it based on something more than 3rd hand waffle :-)

here is my waffle:

PRO:
1. well maintained/developed
2. decent coders involved
3. large/active userbase
4. helpful mailing list
5. lots of docs
6. lots of 'extension' (big word for 'user contributed stuff')
7. proven in production
8. free (as in cost)

CON:
1. overkill for some projects
2. enforces/emphasises/favors a particular design workflow/strategy
3. caching/compile funcrtionality is unclear (I can't figure out how
   to implement it in 'complex' datadriven applications - like for 
instance
   the frontend to a custom webshop system)
4. ability to use php objects in the templates is restricted somwhat
  (much more relevant to usage with php5 objects - e.g. dereferenced 
object method syntax)


now go and read the web, download Smarty and make yuour own mind up.


R. Van Tassel wrote:

I'm contemplating using Smarty Templates for a website and was wondering
what opinions on them, pro or con, may be.

Thanks in advance for all your help.

-Roy



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Controling buffer: php/smarty or apache?

2006-01-23 Thread robert mena
Hi David,

Thanks for the reply.

I am aware of this 'browser' issue but it seems that it's not the case.
I'll look again but since I do not use tables only divs/css I am running out
of option on the html site.


On 1/22/06, David Tulloh [EMAIL PROTECTED] wrote:

 The browsers use a whole bunch of different ways to figure out how it
 should render the page and if it should do it on the fly or wait until
 the page is fully downloaded.

 Assuming the content you are testing is the same for the static and
 dynamic pages you should probably start looking for little things that
 may be different.  From what I've read, adding extra column information
 to the table tag and making sure the doctype is correct so you don't end
 up in quirks mode are both large factors.

 Using 'wget ---save-headers' and 'diff' will help you find any small
 difference between the pages.


 David

 robert mena wrote:
  Hi,
 
  I am facing a strange problem.  My site, even tough designed to appear
  quickly at user's browser, appears at once.  If I test the static HTML
  version it starts to appear as downloaded If I test the php generated
  version the page seems render as a whole.
 
  I am using smarty as a template and it seems to be related to a buffer
  somewhere: php/smarty or apache.
 
  I've used microtime and from the begin of the php script until after the
  smarty-display it takes from 0.05s (min) to 0.32s (max)
 
  Any tips of how can I figure out what is slowing down my site?
 
  tks
 




Re: [PHP] Controling buffer: php/smarty or apache?

2006-01-23 Thread Sumeet

robert mena wrote:


Hi,

I am facing a strange problem.  My site, even tough designed to appear
quickly at user's browser, appears at once.  If I test the static HTML
version it starts to appear as downloaded If I test the php generated
version the page seems render as a whole.

I am using smarty as a template and it seems to be related to a buffer
somewhere: php/smarty or apache.

I've used microtime and from the begin of the php script until after the
smarty-display it takes from 0.05s (min) to 0.32s (max)

Any tips of how can I figure out what is slowing down my site?

tks

 


yes..use cache and use gzip compress...  check http://pear.php.net

if u use cache, that page is generated once and the next time is 
download from the table. php script does take timehence cache always 
helps.


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Controling buffer: php/smarty or apache?

2006-01-22 Thread David Tulloh
The browsers use a whole bunch of different ways to figure out how it
should render the page and if it should do it on the fly or wait until
the page is fully downloaded.

Assuming the content you are testing is the same for the static and
dynamic pages you should probably start looking for little things that
may be different.  From what I've read, adding extra column information
to the table tag and making sure the doctype is correct so you don't end
up in quirks mode are both large factors.

Using 'wget ---save-headers' and 'diff' will help you find any small
difference between the pages.


David

robert mena wrote:
 Hi,
 
 I am facing a strange problem.  My site, even tough designed to appear
 quickly at user's browser, appears at once.  If I test the static HTML
 version it starts to appear as downloaded If I test the php generated
 version the page seems render as a whole.
 
 I am using smarty as a template and it seems to be related to a buffer
 somewhere: php/smarty or apache.
 
 I've used microtime and from the begin of the php script until after the
 smarty-display it takes from 0.05s (min) to 0.32s (max)
 
 Any tips of how can I figure out what is slowing down my site?
 
 tks
 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] PHP smarty - nested queries and arrays

2005-08-12 Thread Daevid Vincent
First I'll appologize for the cheuvanistic remark the other poster had. I
know he had good intentions...

So I don't know smarty, but it seems to me you're grabbing only one row
here:
$projects = $db-getAssoc()

Normally in straight PHP, I would do something like.

While ($row = $db-getAssoc($query, DB_FETCHMODE_ASSOC))
{
$projects[] = $row;
}

The [] just adds a new element to the array and is dumping in the entire
$row array to it.
Ala, multi-dimensional array.

Then I would do something like:

foreach ($projects as $key = $value)
{
echo [.$key.] has a name value of .$value['project_name'];  
}

Remember that you have a multi-array in $projects, so that's why I split it
into the key/value pair where value is actually another array, and you
access the elements via it's hash key.

Hope this helps.

D.Vin
http://daevid.com

 -Original Message-
 $query =SELECT * FROM projects WHERE parent_project_id is NULL OR 
 parent_project_id = '';
  
 $projects = $db-getAssoc($query, DB_FETCHMODE_ASSOC);
  
 foreach ($projects as $key = $project) {
   $query =SELECT * FROM projects WHERE parent_project_id = 
 $projects[$key]['project_id'];
   $sub = $db-getAssoc($query, DB_FETCHMODE_ASSOC);
   $projects[$key]['subs'] = $sub;
 }
 $tpl-assign('projects', $projects);

 SMARTY STUFF
 {foreach from=$projects item='entry'}
 b{$entry.short_name}/bbr /
 ul
 {foreach from=$entry.subs item='sub'}
 li{$sub.short_name}/li
 {foreachelse}
 liNo subs for this project/li
 {/foreach}
 /ul
 {foreachelse}
 bNo projects found/b
 {/foreach}
 
 Can anyone point me in the right direction?
  
 Thanks,
 Amanda
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] PHP smarty - nested queries and arrays

2005-08-11 Thread Amanda Hemmerich

Hello!

I'm using PHP and Smarty to try to build an array of arrays using the 
results from nested queries.  I am just learning about nested arrays, 
and I'm not sure what I'm doing wrong.


I am hoping someone can give me a hint as to what I am doing wrong.  I 
looked on php.net, but still couldn't figure it out.


If I remove the PHP foreach loop, it works fine, except, of course, no 
sub projects show up.   The error must be in there, but I'm just not 
seeing it.


I get the following error with the code below:

Warning: Smarty error: unable to read resource: welcome/Object.tpl in 
/usr/local/lib/php/Smarty/Smarty.class.php on line 1088
  
PHP STUFF
$query =SELECT * FROM projects WHERE parent_project_id is NULL OR 
parent_project_id = '';


$projects = $db-getAssoc($query, DB_FETCHMODE_ASSOC);

foreach ($projects as $key = $project) {
 $query =SELECT * FROM projects WHERE parent_project_id = 
$projects[$key]['project_id'];

 $sub = $db-getAssoc($query, DB_FETCHMODE_ASSOC);
 $projects[$key]['subs'] = $sub;
}
$tpl-assign('projects', $projects);
  
SMARTY STUFF

{foreach from=$projects item='entry'}
   b{$entry.short_name}/bbr /
   ul
   {foreach from=$entry.subs item='sub'}
   li{$sub.short_name}/li
   {foreachelse}
   liNo subs for this project/li
   {/foreach}
   /ul
{foreachelse}
   bNo projects found/b
{/foreach}

Can anyone point me in the right direction?

Thanks,
Amanda

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: PHP smarty - nested queries and arrays

2005-08-11 Thread Matthew Weier O'Phinney
* Amanda Hemmerich [EMAIL PROTECTED]:
 I'm using PHP and Smarty to try to build an array of arrays using the 
 results from nested queries.  I am just learning about nested arrays, 
 and I'm not sure what I'm doing wrong.
  
 I am hoping someone can give me a hint as to what I am doing wrong.  I 
 looked on php.net, but still couldn't figure it out.
  
 If I remove the PHP foreach loop, it works fine, except, of course, no 
 sub projects show up.   The error must be in there, but I'm just not 
 seeing it.
  
 I get the following error with the code below:
  
 Warning: Smarty error: unable to read resource: welcome/Object.tpl in 
 /usr/local/lib/php/Smarty/Smarty.class.php on line 1088

Actually, this error indicates it either cannot find or open the
template file. make sure you have a 'welcome' directory in your
templates directory, and an Object.tpl file within -- and that they have
permissions such that the web server can open them.

-- 
Matthew Weier O'Phinney
Zend Certified Engineer
http://weierophinney.net/matthew/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] PHP smarty - nested queries and arrays

2005-08-11 Thread Jochem Maas

Amanda Hemmerich wrote:

Hello!

I'm using PHP and Smarty to try to build an array of arrays using the 
results from nested queries.  I am just learning about nested arrays, 
and I'm not sure what I'm doing wrong.


...



Can anyone point me in the right direction?


Amanda please don't cross-post. it's bad karma, ok your a
girl (or woman - you choose :-) so we'll let you off this time
(and the next, and the next)

... that's not to say girls are crap at IT/programming/etc it's just
we don't have enough girls on this list ;-)

(actually one of the php core devs is a girl and she's damn good
AFAICT - Sara Golemon is her name - she wrote the 'blackmagic' runkit
extension which deserves a round of applause all on it own!)




Thanks,
Amanda



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Tip for 'New People'/Beginners/Noobs [was] Re: [PHP] PHP smarty - nested queries and arrays

2005-08-11 Thread Jochem Maas

Amanda Hemmerich wrote:

What is cross posting?


when you post the same question to
more than one mailing list (especially when done
at the same time).

alot of the people who regularly read/post on php-generals
also watch other php related mailing lists (I for one
am also subscribed to the Smarty list - actually I'm subscribed
to nearly all the php lists :-P)

as a sidenote - always try to show that you have researched your
problem properly - chances are people will be _much_ more willing to help
you (regardless of how simple the question might be for people who
have been playing the web/php game for a while :-)

and don't take it too personally if you get an occasional STFW or RTFM,
consider it like medicine - it tastes bad but its good for you :-)



Thanks,
Amanda

Jochem Maas wrote:


Amanda Hemmerich wrote:


Hello!

I'm using PHP and Smarty to try to build an array of arrays using the 
results from nested queries.  I am just learning about nested arrays, 
and I'm not sure what I'm doing wrong.




...



Can anyone point me in the right direction?




Amanda please don't cross-post. it's bad karma, ok your a
girl (or woman - you choose :-) so we'll let you off this time
(and the next, and the next)

... that's not to say girls are crap at IT/programming/etc it's just
we don't have enough girls on this list ;-)

(actually one of the php core devs is a girl and she's damn good
AFAICT - Sara Golemon is her name - she wrote the 'blackmagic' runkit
extension which deserves a round of applause all on it own!)




Thanks,
Amanda





--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: PHP smarty - nested queries and arrays

2005-08-11 Thread mikespook
Warning: Smarty error: unable to read resource: welcome/Object.tpl in
/usr/local/lib/php/Smarty/Smarty.class.php on line 1088

You should check your Smarty`s template_dir. Put the templates into the 
template_dir, then the Smarty will find them.

Like this:

$smarty = new Smarty();
$smarty-template_dir = '/home/mike/tpl/';
$smarty-display('test.tpl');

You should put the file 'test.tpl' into dir '/home/mike/tpl'.

Amanda Hemmerich [EMAIL PROTECTED] 
??:[EMAIL PROTECTED]
 Hello!

 I'm using PHP and Smarty to try to build an array of arrays using the 
 results from nested queries.  I am just learning about nested arrays, and 
 I'm not sure what I'm doing wrong.

 I am hoping someone can give me a hint as to what I am doing wrong.  I 
 looked on php.net, but still couldn't figure it out.

 If I remove the PHP foreach loop, it works fine, except, of course, no sub 
 projects show up.   The error must be in there, but I'm just not seeing 
 it.

 I get the following error with the code below:
 Warning: Smarty error: unable to read resource: welcome/Object.tpl 
 in /usr/local/lib/php/Smarty/Smarty.class.php on line 1088
   PHP STUFF
 $query =SELECT * FROM projects WHERE parent_project_id is NULL OR 
 parent_project_id = '';

 $projects = $db-getAssoc($query, DB_FETCHMODE_ASSOC);

 foreach ($projects as $key = $project) {
  $query =SELECT * FROM projects WHERE parent_project_id = 
 $projects[$key]['project_id'];
  $sub = $db-getAssoc($query, DB_FETCHMODE_ASSOC);
  $projects[$key]['subs'] = $sub;
 }
 $tpl-assign('projects', $projects);
   SMARTY STUFF
 {foreach from=$projects item='entry'}
b{$entry.short_name}/bbr /
ul
{foreach from=$entry.subs item='sub'}
li{$sub.short_name}/li
{foreachelse}
liNo subs for this project/li
{/foreach}
/ul
 {foreachelse}
bNo projects found/b
 {/foreach}

 Can anyone point me in the right direction?

 Thanks,
 Amanda 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] SMarty and commercial php (a little 0t)

2005-05-22 Thread M Saleh EG
I'd recommand you to use the HTML_TEMPLATE_IT. It's a PEAR class for 
templating; I've personaly worked on it for building skinnable applications 
in which users and admins can change the look of the pages. Bottom line, 
it's a PEAR library/extension so no hastle since most of the hosts include 
it in their PHP installations. This template does alot of handy jobs such as 
nested blocks templating and rendering. However, it does not have the bells 
and the whistles of Smarty. Simply it does the job, it's efficient, and very 
elegant since your HTML templates would have only 2 extra stuff. One which 
is the HTML style comments to define and close blocks and the, Two which is 
the variable names to be placed whithin curly braces. So templating does not 
realy have a language in IT it's just a ditributed method of writing HTML 
and feeding data which forms another Tier in your application not another 
Application by itself.
 Benefits you'll get by using this PEAR library/extension is that you 
wouldnt need to tutor the designers on how to use a procedural markup 
templating language hence more flexibility and shorter learning curve. And 
plus it does not need no configuration and you could write your own nice 
wrapper classes to do special things for you, such as rendering pages 
templates, or blockwise template files with predefined variable to be 
inserted in the template files simple as that. e.g. you could write a 
function or a class method to route template files and then only pass them 
an array and the function would do the whole thing from rendering to 
displaying. especialy if you use the Web Standards and Semantic Design 
skinning would mean only switching CSSs and slight changes in your 
structural markup(template files).
 Note: If by any change your ISP/Host does not have the PEAR package 
installed you could just put it in a directory and simply append it to your
include_dir directive so that you could include/require the class file (only 
1 file is the whole package) directly w/o routing to its location.
 I'd honestly never implement Smarty for an application I'd work alone on 
and then give it up to designers I'd use Smarty while working with team 
mates of the same range of understanding of the Web Dev/ Design in a team 
environment for better performance and that's only if the application 
screens are more than 100 and the administration. 
 HTH.
 M.Saleh.E.G
97150-4779817


[PHP] SMarty and commercial php (a little 0t)

2005-05-21 Thread Ryan A
Hey,
This may belong more on the smarty list, but I thought i'll ask it here
because
in another way I need your opinion more than smarty advise.

Like a lot of people on this list, I use a templating system (Smarty and
another...
mostly Smarty) when I am working on a project for a client...
Reason: when he wants to make a design change..I dont kill him...or his
family :-)

Now I am faced with another situatation, I have been assigned a project
(working
freelance) to make a pretty simple piece of software which also includes 2
admin panels
(one for client and one for admin)
He wants to be able to skin the admin panel at will, which means, easiest
solution:
Template the sod.

I was wondering if its a good idea to template via smarty and include smarty
with my code?
also instructions to setup smarty when setting up the application i made?

Searching google I found this very nice place discussing PHP templating (you
might also want to
read up on how many there are!)
http://www.sitepoint.com/forums/showthread.php?t=123769page=1pp=25
but no discussion of including any of these with commercial software for the
client to setup and
their results.

Thanks,
Ryan



-- 
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.322 / Virus Database: 266.11.14 - Release Date: 5/20/2005

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] SMarty and commercial php (a little 0t)

2005-05-21 Thread Rory Browne
 I was wondering if its a good idea to template via smarty and include smarty
 with my code?
 also instructions to setup smarty when setting up the application i made?

Good idea compared to what? Compared to a different templating
library, compared to writing your own templating library, or compared
to having them download/install smarty themselves as a dependency?


 Searching google I found this very nice place discussing PHP templating (you
 might also want to read up on how many there are!)
 http://www.sitepoint.com/forums/showthread.php?t=123769page=1pp=25
 but no discussion of including any of these with commercial software for the
 client to setup and their results.

Smarty is licensed under the LGPL. I've never read the LGPL, but
TTBOMK that means you can use it in commercial/propriatory software,
which I'm assuming is what you're refering to.

 
 Thanks,
 Ryan
 
 
 
 --
 No virus found in this outgoing message.
 Checked by AVG Anti-Virus.
 Version: 7.0.322 / Virus Database: 266.11.14 - Release Date: 5/20/2005
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] SMarty and commercial php (a little 0t)

2005-05-21 Thread Ryan A
Hey,

  I was wondering if its a good idea to template via smarty and include
 smarty
  with my code?
  also instructions to setup smarty when setting up the application i
 made?

 Good idea compared to what? Compared to a different templating
 library, compared to writing your own templating library, or compared
 to having them download/install smarty themselves as a dependency?

Yep, left myself quite open there...should have been more specific.
I will not write a templating library myself because there are so many
out there,
it would be a learning experience of course but other than that I think it
would be
rarely needed.
I meant bundling it along with the rest of the scripts, (which would add
around 500kb to the
size) and then giving instructions on how to do a basic configuration for
smarty.



  Searching google I found this very nice place discussing PHP templating
 (you
  might also want to read up on how many there are!)
  http://www.sitepoint.com/forums/showthread.php?t=123769page=1pp=25
  but no discussion of including any of these with commercial software for
 the
  client to setup and their results.

 Smarty is licensed under the LGPL.
 I've never read the LGPL, but
 TTBOMK that means you can use it in commercial/propriatory software,
 which I'm
 assuming is what you're refering to.

Nope, sorry, I should have been more specific here too.
I meant what I said above...nobody has discussed what experience they have
had if they
bundled smarty along with their scripts and then told the client how to
configure smarty
or if the clients had any problem configuring smarty etc.

Cheers,
Ryan



-- 
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.322 / Virus Database: 266.11.14 - Release Date: 5/20/2005

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] SMarty and commercial php (a little 0t)

2005-05-21 Thread Rory Browne
 Yep, left myself quite open there...should have been more specific.
 I will not write a templating library myself because there are so many
 out there,
 it would be a learning experience of course but other than that I think it
 would be
 rarely needed.
 I meant bundling it along with the rest of the scripts, (which would add
 around 500kb to the
 size) and then giving instructions on how to do a basic configuration for
 smarty.
I've never done it personally, but if this is for one specific client,
isn't 500k pretty much insignificant? If it's a problem though,
perhaps you could use a smaller template system, that maybe required
less configuration. Having that said, I've never used Smarty so I
don't know what configuration is involved. Perhaps an auto-config
script could be made?

 
 
 
   Searching google I found this very nice place discussing PHP templating
  (you
   might also want to read up on how many there are!)
   http://www.sitepoint.com/forums/showthread.php?t=123769page=1pp=25
   but no discussion of including any of these with commercial software for
  the
   client to setup and their results.
 
  Smarty is licensed under the LGPL.
  I've never read the LGPL, but
  TTBOMK that means you can use it in commercial/propriatory software,
  which I'm
  assuming is what you're refering to.
 
 Nope, sorry, I should have been more specific here too.
 I meant what I said above...nobody has discussed what experience they have
 had if they
 bundled smarty along with their scripts and then told the client how to
 configure smarty
 or if the clients had any problem configuring smarty etc.
 
 Cheers,
 Ryan
 
 
 
 --
 No virus found in this outgoing message.
 Checked by AVG Anti-Virus.
 Version: 7.0.322 / Virus Database: 266.11.14 - Release Date: 5/20/2005
 


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Smarty and PEAR DB

2005-04-11 Thread Reynier Perez Mira
Hello List:

I'm using PEAR DB and Smarty. The case is that I have to pass a value from a 
query result to a Smarty var. I try to paginate results. See the code below:

///

SmartyPaginate::connect();
SmartyPaginate::setLimit(5);
$gbresult = $database-query(SELECT * FROM libro_de_visitas LIMIT  . 
SmartyPaginate::getCurrentIndex() . , . SmartyPaginate::getLimit());
$gbtotal = $database-query(SELECT COUNT(*) AS total FROM libro_de_visitas);
$gbtotal-fetchRow();
SmartyPaginate::setTotal($gbtotal['total']);

///

As you can see I need the COUNT value but I not know how get it from query 
using PEAR. Some body can help me?

Regards

 

Reynier Pérez Mira

3ero. Ing. Informática

Entre más inteligente me siento, más me doy cuenta de lo ignorante que soy. 

 



[PHP] smarty and db

2004-08-03 Thread Amanda Hemmerich
Ok, I am starting a new job and learning a new person's code, and trying
to learn Smarty at the same time.

This question is so basic, but I have no idea where to look for an answer.

ANyway, I need to change the code so that, when there are no row returned
by the database, a message is displayed saying, There are no events
scheduled. or what have you.

Now, the way I would have done this before using smarty would be to check 
the number of records, and if there were none, I would display the
message, otherwise, I would loop through and display the results,

However, I know one of the points of smarty is to keep code out of the
presentation layer, so I don't want to go into the template and add an if
statement in there.

Any help directing me to an example or whatever would be helpful.

Here is what is going on right now in the code:

(in the PHP page)
$events = $db-getAll($sql_events, DB_FETCHMODE_ASSOC);
$tpl-assign(events,$events);

(in the template page)
{section name=id loop=$events}
tr
td class=event
b{$events[id].type}/b: a class=menulink
href={$url_prefix}/community/events/?id={$events[id].id}{$events[id].date|date_format:%B
%e, %Y}, {$events[id].speaker}/abr /
{$events[id].title}
/td
/tr
{/section}

Thanks,
Amanda

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] smarty and db

2004-08-03 Thread John Nichel
On Tuesday 03 August 2004 15:21, Amanda Hemmerich offered up the following 
tid-bit of information :
 Ok, I am starting a new job and learning a new person's code, and trying
 to learn Smarty at the same time.

 This question is so basic, but I have no idea where to look for an
 answer.

 ANyway, I need to change the code so that, when there are no row returned
 by the database, a message is displayed saying, There are no events
 scheduled. or what have you.

 Now, the way I would have done this before using smarty would be to check
 the number of records, and if there were none, I would display the
 message, otherwise, I would loop through and display the results,

 However, I know one of the points of smarty is to keep code out of the
 presentation layer, so I don't want to go into the template and add an if
 statement in there.

 Any help directing me to an example or whatever would be helpful.

 Here is what is going on right now in the code:

 (in the PHP page)
 $events = $db-getAll($sql_events, DB_FETCHMODE_ASSOC);
 $tpl-assign(events,$events);

 (in the template page)
 {section name=id loop=$events}
 tr
 td class=event
 b{$events[id].type}/b: a class=menulink
 href={$url_prefix}/community/events/?id={$events[id].id}{$events[id].d
ate|date_format:%B %e, %Y}, {$events[id].speaker}/abr /
 {$events[id].title}
 /td
 /tr
 {/section}

 Thanks,
 Amanda

According to this page 
http://smarty.php.net/manual/en/language.function.if.php you should be able 
to do something like.

{ if is_array ( $events ) }
do smarty stuff
{ /if }

-- 
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] smarty and db

2004-08-03 Thread Justin Patrin
On Tue, 3 Aug 2004 14:21:45 -0500 (EST), Amanda Hemmerich
[EMAIL PROTECTED] wrote:
 Ok, I am starting a new job and learning a new person's code, and trying
 to learn Smarty at the same time.
 
 This question is so basic, but I have no idea where to look for an answer.
 
 ANyway, I need to change the code so that, when there are no row returned
 by the database, a message is displayed saying, There are no events
 scheduled. or what have you.
 
 Now, the way I would have done this before using smarty would be to check
 the number of records, and if there were none, I would display the
 message, otherwise, I would loop through and display the results,
 
 However, I know one of the points of smarty is to keep code out of the
 presentation layer, so I don't want to go into the template and add an if
 statement in there.
 
 Any help directing me to an example or whatever would be helpful.
 
 Here is what is going on right now in the code:
 
 (in the PHP page)
 $events = $db-getAll($sql_events, DB_FETCHMODE_ASSOC);
 $tpl-assign(events,$events);
 
 (in the template page)
 {section name=id loop=$events}
 tr
 td class=event
 b{$events[id].type}/b: a class=menulink
 href={$url_prefix}/community/events/?id={$events[id].id}{$events[id].date|date_format:%B
 %e, %Y}, {$events[id].speaker}/abr /
 {$events[id].title}
 /td
 /tr
 {/section}
 

My solution to this would be to change the template. IMHO it's a
view funciton to display something different when there is no data.

However, if you're averse to that, I would suggest using a different template.

-- 
DB_DataObject_FormBuilder - The database at your fingertips
http://pear.php.net/package/DB_DataObject_FormBuilder

paperCrane --Justin Patrin--

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] smarty and db

2004-08-03 Thread John Holmes
Amanda Hemmerich wrote:
ANyway, I need to change the code so that, when there are no row returned
by the database, a message is displayed saying, There are no events
scheduled. or what have you.
[snip]
(in the PHP page)
$events = $db-getAll($sql_events, DB_FETCHMODE_ASSOC);
$tpl-assign(events,$events);
(in the template page)
{section name=id loop=$events}
tr
td class=event
b{$events[id].type}/b: a class=menulink
href={$url_prefix}/community/events/?id={$events[id].id}{$events[id].date|date_format:%B
%e, %Y}, {$events[id].speaker}/abr /
{$events[id].title}
/td
/tr
{/section}
{section name=id loop=$events}
...
{sectionelse}
No results
{/section}
--
John Holmes
php|architect - The magazine for PHP professionals - http://www.phparch.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


AW: [PHP] smarty

2004-04-16 Thread Ben
But i don't see an alternative in your Example 3.
I hate that coding mixed up with the rest of HTML/CSS.
It may be fact, that the perfomance could get worse a bit
when using smarty* but since your not coding sth. for a high
traffic site the usability of code is more important than that
little peace of loss in performance.
Nevertheless it might be a neverending discussion like 
windows vs *nix...


-Ursprüngliche Nachricht-
Von: Chris de Vidal [mailto:[EMAIL PROTECTED] 
Gesendet: Mittwoch, 14. April 2004 17:34
An: Kelly Hallman
Cc: [EMAIL PROTECTED]
Betreff: Re: [PHP] smarty


 To make that claim, you're dropping a pretty heavy dis on a lot of 
 people who have invested a great deal of time, effort, and 
 subsequently realized great benefits from Smarty and it's templating 
 brethren. Not to mention all those who have devoted great effort in 
 the development of these tools.

I believe it and most templating engines were written because many
people didn't know they had an alternative.  I could be wrong; if so, it
is a heavy dis.  Didn't mean it that way, so if I am wrong I humbly
apologize.


---
__
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.657 / Virus Database: 422 - Release Date: 13.04.2004
 

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: AW: [PHP] smarty

2004-04-16 Thread Chris de Vidal
Ben said:
 But i don't see an alternative in your Example 3.

Here was example 3 from my post:
http://marc.theaimsgroup.com/?l=php-generalm=108145205519710w=2

$result = mysql_query (SELECT * FROM users WHERE id = '.$_GET[id].');
$row_array = mysql_fetch_array ($result);
$name= $row_array[name];
$address = $row_array[address];
$state   = $row_array[state];
$include(template.tpl);
---
html
body
Name: ?=$name;?br
Address: ?=$address;?br
State: ?=$state;?br
...

By the way, that's 2 files you're looking at; something like index.php and
template.tpl.

Looks rather templaty, dontcha think?  PHP was originally intended to be a
template engine (or so I've been told).

 I hate that coding mixed up with the rest of HTML/CSS.

Me too, which is why I went to Smarty, but then I realized I could do the
same thing without Smarty.  Not that Smarty is bad (I'll probably use it
in the future) but I don't *need* it to separate business and presentation
logic and neither do you.

For further separation of design from markup, check out CSSZenGarden.com
for about 200 amazing designs done entirely with CSS.  Seems there's no
limits to the design capabilities of CSS, including replacing HTML tables
and img tags.

Ultimately you could separate your entire website into CSS for design,
HTML for the markup of the data, PHP for getting the data, etc.  Very
nice.

 It may be fact, that the perfomance could get worse a bit
 when using smarty* but since your not coding sth. for a high
 traffic site the usability of code is more important than that
 little peace of loss in performance.

I agree.  The ease-of-use that templating affords is a good tradeoff for
the slight performance hit.  Smarty does precompile the PHP and offers
caching, which helps... it's probably similar in performance to the native
PHP template method described above.  With native PHP I can use buffering
and Zend and other native performance goodness so native PHP is almost
certainly going to be faster in nearly every case.  Just my guess.

Overall, I'd use Smarty when I want to get the extra functions and widgets
in one library.  It's a great tool.

/dev/idal

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: AW: [PHP] smarty

2004-04-16 Thread pete M
I don't see why you keep persisting this thread.

Smarty is a cool tool and lots of people use it. You have decided NOT to 
use it.

So why keep going on; you not like Smarty; are you encouraging users not 
to use Smarty. I don't see your point at all !!!

There's more than one way of skinning a cat !

pete

Chris De Vidal wrote:
Ben said:

But i don't see an alternative in your Example 3.


Here was example 3 from my post:
http://marc.theaimsgroup.com/?l=php-generalm=108145205519710w=2
$result = mysql_query (SELECT * FROM users WHERE id = '.$_GET[id].');
$row_array = mysql_fetch_array ($result);
$name= $row_array[name];
$address = $row_array[address];
$state   = $row_array[state];
$include(template.tpl);
---
html
body
Name: ?=$name;?br
Address: ?=$address;?br
State: ?=$state;?br
...
By the way, that's 2 files you're looking at; something like index.php and
template.tpl.
Looks rather templaty, dontcha think?  PHP was originally intended to be a
template engine (or so I've been told).

I hate that coding mixed up with the rest of HTML/CSS.


Me too, which is why I went to Smarty, but then I realized I could do the
same thing without Smarty.  Not that Smarty is bad (I'll probably use it
in the future) but I don't *need* it to separate business and presentation
logic and neither do you.
For further separation of design from markup, check out CSSZenGarden.com
for about 200 amazing designs done entirely with CSS.  Seems there's no
limits to the design capabilities of CSS, including replacing HTML tables
and img tags.
Ultimately you could separate your entire website into CSS for design,
HTML for the markup of the data, PHP for getting the data, etc.  Very
nice.

It may be fact, that the perfomance could get worse a bit
when using smarty* but since your not coding sth. for a high
traffic site the usability of code is more important than that
little peace of loss in performance.


I agree.  The ease-of-use that templating affords is a good tradeoff for
the slight performance hit.  Smarty does precompile the PHP and offers
caching, which helps... it's probably similar in performance to the native
PHP template method described above.  With native PHP I can use buffering
and Zend and other native performance goodness so native PHP is almost
certainly going to be faster in nearly every case.  Just my guess.
Overall, I'd use Smarty when I want to get the extra functions and widgets
in one library.  It's a great tool.
/dev/idal
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: AW: [PHP] smarty

2004-04-16 Thread John Nichel
pete M wrote:
There's more than one way of skinning a cat !
Hydrochloric acid works real well. ;)

--
***
*  _  __   __  __   _  * John  Nichel *
* | |/ /___ __ \ \/ /__ _ _| |__ ___  __ ___ _ __  * 716.856.9675 *
* | ' / -_) _` \ \/\/ / _ \ '_| / /(_-_/ _/ _ \ '  \ * 737 Main St. *
* |_|\_\___\__, |\_/\_/\___/_| |_\_\/__(_)__\___/_|_|_|* Suite #150   *
*  |___/   * Buffalo, NY  *
* http://www.KegWorks.com[EMAIL PROTECTED] * 14203 - 1321 *
***
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: AW: [PHP] smarty

2004-04-16 Thread Chris de Vidal
pete M said:
 Smarty is a cool tool and lots of people use it. You have decided NOT to
 use it.

I don't believe you've read a word I've written.

I've been trying to tell people like myself that one can easily template
with PHP.  I thought I *needed* Smarty or any nice templating engine to
seperate business and presentation logic; I was wrong.  I was ignorant and
perhaps there are others like me.

I've also been saying that I'll probably use Smarty in the future.
Advantages: numerous time-saving built-in functions, performance (debatable)
Disadvantages: must learn yet another language and work with that
language's shortcomings.

I never said I've decided NOT to use it.  I've never said it wasn't a cool
tool.  Please read carefully.

/dev/idal

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: AW: [PHP] smarty

2004-04-16 Thread Richard Harb
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Could we please close the thread already?

I think in the previous week there's been everything said what there's
been to say. whoever is still interested in reading the same arguments
over and over should please take a look at the archives.

I value the opinion of every poster if (s)he has something to
contribute - but contribution also includes adding something not
already present in abundance.

... and I really don't want to killfile any members of this list.

Thanks

Richard

PS: sorry if it sounds kinda pissed.



Friday, April 16, 2004, 4:10:20 PM, you wrote:

 pete M said:
 Smarty is a cool tool and lots of people use it. You have decided NOT to
 use it.

 I don't believe you've read a word I've written.

 I've been trying to tell people like myself that one can easily template
 with PHP.  I thought I *needed* Smarty or any nice templating engine to
 seperate business and presentation logic; I was wrong.  I was ignorant and
 perhaps there are others like me.

 I've also been saying that I'll probably use Smarty in the future.
 Advantages: numerous time-saving built-in functions, performance (debatable)
 Disadvantages: must learn yet another language and work with that
 language's shortcomings.

 I never said I've decided NOT to use it.  I've never said it wasn't a cool
 tool.  Please read carefully.

 /dev/idal

-BEGIN PGP SIGNATURE-
Version: PGPsdk 2.0.5 Copyright (C) 2001 Networks Associates Technology, Inc. All 
rights reserved.
Comment: 

iQA/AwUBQH/ti0LEeLYDwe5mEQKW2ACeKc1lBSCJe4x8cMmbjt6Fii87koQAnRHl
q70qB+EHK8HlwhVnCok+wfTm
=NyMA
-END PGP SIGNATURE-

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: AW: [PHP] smarty

2004-04-16 Thread Enrico Weigelt

BIG_SNIP /

It seems the discussions wents in a completely nonsense direction.

Arguing about TE's in general and one concerete TE named smarty 
is simply silly.

Either we'd talk about the (dis)advantages of TE's in general 
or compare different TE's, i.e. smarty vs. pattemplate vs. xslt.

So lets split the thread into the two different topics and talk 
about them separately. Instead arguing apples are tasting better
than bananas since because of the different color is simply nonesense.


cu
-- 
-
 Enrico Weigelt==   metux IT services

  phone: +49 36207 519931 www:   http://www.metux.de/
  fax:   +49 36207 519932 email: [EMAIL PROTECTED]
  cellphone: +49 174 7066481
-
   -- DSL-Zugang ab 0 Euro. -- statische IP -- UUCP -- Hosting --
-

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: AW: [PHP] smarty

2004-04-16 Thread Chris W. Parker
Enrico Weigelt mailto:[EMAIL PROTECTED]
on Friday, April 16, 2004 10:13 AM said:

keep in mind it's friday!!

 Either we'd talk about the (dis)advantages of TE's in general
 or compare different TE's, i.e. smarty vs. pattemplate vs. xslt.

don't forget interjinn.

 So lets split the thread into the two different topics and talk
 about them separately. Instead arguing apples are tasting better
 than bananas since because of the different color is simply nonesense.

actually i think bananas are better because of their shape.


...


wait. i think that came out wrong.





chris.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: AW: [PHP] smarty

2004-04-16 Thread John Nichel
Chris W. Parker wrote:
Enrico Weigelt mailto:[EMAIL PROTECTED]
on Friday, April 16, 2004 10:13 AM said:
keep in mind it's friday!!
Then why am I still sober?

Either we'd talk about the (dis)advantages of TE's in general
or compare different TE's, i.e. smarty vs. pattemplate vs. xslt.


don't forget interjinn.
Like we ever could.

(awaits the flame)

So lets split the thread into the two different topics and talk
about them separately. Instead arguing apples are tasting better
than bananas since because of the different color is simply nonesense.


actually i think bananas are better because of their shape.
I won't touch that with a ten foot banana.

wait. i think that came out wrong.
Better than going in wrong.

(Isn't it 5:00 yet???)

--
***
*  _  __   __  __   _  * John  Nichel *
* | |/ /___ __ \ \/ /__ _ _| |__ ___  __ ___ _ __  * 716.856.9675 *
* | ' / -_) _` \ \/\/ / _ \ '_| / /(_-_/ _/ _ \ '  \ * 737 Main St. *
* |_|\_\___\__, |\_/\_/\___/_| |_\_\/__(_)__\___/_|_|_|* Suite #150   *
*  |___/   * Buffalo, NY  *
* http://www.KegWorks.com[EMAIL PROTECTED] * 14203 - 1321 *
***
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: AW: [PHP] smarty

2004-04-16 Thread Robert Cummings
On Fri, 2004-04-16 at 13:27, John Nichel wrote:
 Chris W. Parker wrote:
  Enrico Weigelt mailto:[EMAIL PROTECTED]
  on Friday, April 16, 2004 10:13 AM said:
  
  keep in mind it's friday!!
 
 Then why am I still sober?
 
 Either we'd talk about the (dis)advantages of TE's in general
 or compare different TE's, i.e. smarty vs. pattemplate vs. xslt.
  
  don't forget interjinn.
 
 Like we ever could.
 (awaits the flame)

John WHY ARE YOU SUCH A F... Ok, I'm willing to let bad blood go away if
you are. We're all PHP peeps here so really there shouldn't be any
animosity (perceived or otherwise).

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: AW: [PHP] smarty

2004-04-16 Thread Aaron Wolski
   don't forget interjinn.
 
  Like we ever could.
  (awaits the flame)
 
 John WHY ARE YOU SUCH A F... Ok, I'm willing to let bad blood go away 
 if you are. We're all PHP peeps here so really there shouldn't be any 
 animosity (perceived or otherwise).

Damn. Some of the best entertainment of my week on this list ;)

*home simpson voice* m beer.

Enjoy all.

A

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: AW: [PHP] smarty

2004-04-16 Thread John Nichel
Aaron Wolski wrote:
don't forget interjinn.
Like we ever could.
(awaits the flame)
John WHY ARE YOU SUCH A F... Ok, I'm willing to let bad blood go away 
if you are. We're all PHP peeps here so really there shouldn't be any 
animosity (perceived or otherwise).


Damn. Some of the best entertainment of my week on this list ;)

*home simpson voice* m beer.

Enjoy all.

A
You should try the qmail list.

--
***
*  _  __   __  __   _  * John  Nichel *
* | |/ /___ __ \ \/ /__ _ _| |__ ___  __ ___ _ __  * 716.856.9675 *
* | ' / -_) _` \ \/\/ / _ \ '_| / /(_-_/ _/ _ \ '  \ * 737 Main St. *
* |_|\_\___\__, |\_/\_/\___/_| |_\_\/__(_)__\___/_|_|_|* Suite #150   *
*  |___/   * Buffalo, NY  *
* http://www.KegWorks.com[EMAIL PROTECTED] * 14203 - 1321 *
***
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: AW: [PHP] smarty

2004-04-16 Thread John W. Holmes
  Either we'd talk about the (dis)advantages of TE's in general
  or compare different TE's, i.e. smarty vs. pattemplate vs. xslt.

Wait a minute... are we talking about Smarty as in smarty.php.net? Because I
was thinking of something else this entire time and this completely changes
the discussion...

---John Holmes... ;)

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: AW: [PHP] smarty

2004-04-16 Thread John Nichel
John W. Holmes wrote:
Either we'd talk about the (dis)advantages of TE's in general
or compare different TE's, i.e. smarty vs. pattemplate vs. xslt.


Wait a minute... are we talking about Smarty as in smarty.php.net? Because I
was thinking of something else this entire time and this completely changes
the discussion...
---John Holmes... ;)

There's a smarty.php.net?

No wonder I was getting so confused going to www.smarty.com

serious
You do realize that with 2.5 hours left in the work day today, we're 
likely to get even sillier? ;)
/serious

--
***
*  _  __   __  __   _  * John  Nichel *
* | |/ /___ __ \ \/ /__ _ _| |__ ___  __ ___ _ __  * 716.856.9675 *
* | ' / -_) _` \ \/\/ / _ \ '_| / /(_-_/ _/ _ \ '  \ * 737 Main St. *
* |_|\_\___\__, |\_/\_/\___/_| |_\_\/__(_)__\___/_|_|_|* Suite #150   *
*  |___/   * Buffalo, NY  *
* http://www.KegWorks.com[EMAIL PROTECTED] * 14203 - 1321 *
***
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: AW: [PHP] smarty

2004-04-16 Thread Chris W. Parker
John Nichel mailto:[EMAIL PROTECTED]
on Friday, April 16, 2004 11:24 AM said:

 serious
 You do realize that with 2.5 hours left in the work day today, we're
 likely to get even sillier? ;)
 /serious

I still have 6 hours to go. :(




c.

p.s. anyone play ffxi?

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] smarty

2004-04-14 Thread Chris de Vidal
pete M said:
 what about the modifiers
long list of modifiers snipped
 How would you code that lot and remember its ALL to do with presentation ?

I mentioned this.  Take another look at my post:
http://marc.theaimsgroup.com/?l=php-generalm=108145205519710w=2
[By using only PHP], At worst [I lose] some of the nice
Smarty functions such as html_options (which might be easily replaced by
phpHTMLlib or another widget library).

So there are alternatives to what Smarty offers, but I also said I just
see them [template engines] as another tool.  It's a tool; use it where
it saves time, but it's not as if native PHP lacks most (if not all) of
what Smarty offers, which is what I originally thought because I'd learned
PHP by spaghetti coding.

I would never say that Smarty is completely redundant.  Use it where it
makes sense.  But now that my eyes have been opened I believe it's
_mostly_ redundant.  I believe it was written because so many people
aren't aware that native PHP is a *very* effective template engine.

/dev/idal

P.S. Have a look at the article I linked in my post:
http://www.phppatterns.com/index.php/article/articleview/4/1/1/

While I don't totally agree with everything he says (he says ALL
templating engines are bad), it was an eye-opener for me.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] smarty

2004-04-14 Thread Chris de Vidal
Vicente Werner said:
  http://marc.theaimsgroup.com/?l=php-generalm=108145205519710w=2
 Ugh that's not just fuckingly ugly, but a total doom to maintain over the
 time -two months without touching the code and you're absolutely lost- .
 It maybe faster, it maybe a bit simpler since you only have to learn one
 language, but it's a mental carnage to maintain a client site that way

I don't understand... how is this:
==
$page = new Smarty();
$result = mysql_query (SELECT * FROM users WHERE id = '.$_GET[id].');
$row_array = mysql_fetch_array ($result);
$page-assign(name,$row_array[name]);
$page-assign(address, $row_array[address]);
$page-assign(state,   $row_array[state]);
$page-display(template.tpl);
---
html
body
Name: {$name}br
Address: {$address}br
State: {$state}br
...
===


Better than this?
=
$result = mysql_query (SELECT * FROM users WHERE id = '.$_GET[id].');
$row_array = mysql_fetch_array ($result);
$name= $row_array[name];
$address = $row_array[address];
$state   = $row_array[state];
$include(template.tpl);
---
html
body
Name: ?=$name;?br
Address: ?=$address;?br
State: ?=$state;?br
...
===

They both look about the same (well in the native PHP example I actually
wrote less code).

Perhaps you were looking at my spaghetti-code example, but take another
look, I posted 3 examples.

/dev/idal

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re[2]: [PHP] smarty

2004-04-14 Thread Richard Davey
Hello Chris,

Wednesday, April 14, 2004, 3:35:05 PM, you wrote:

CdV I don't understand... how is this:
[snip]
CdV Better than this?
CdV =
CdV $result = mysql_query (SELECT * FROM users WHERE id = '.$_GET[id].');
CdV $row_array = mysql_fetch_array ($result);
CdV $name= $row_array[name];
CdV $address = $row_array[address];
CdV $state   = $row_array[state];
CdV $include(template.tpl);
CdV ---
CdV html
CdV body
CdV Name: ?=$name;?br
CdV Address: ?=$address;?br
CdV State: ?=$state;?br
CdV ...
CdV ===

Because you're injecting variables directly into your HTML, which some
of the time might be ok - but what if the $row_array doesn't contain
name ? You'll raise an Error Warning without first passing it
through some kind of test (or function).

You assume that the PHP short-tags are enabled (? ?) for
echoing variables and while most the time they are, you shouldn't bank
on it in code (incidentally, you don't need the trailing ; on the
short-tag echos).

Sure - these things can be fixed easily, but then that isn't the point
- if you think about it logically, anything Smarty can do, PHP can do
too (well, duh! :)

But what if you want to take your template and perform a bit more than
just mere variable substitution on it? How about highlighting all
words that match a search term, or applying logic to a display block
based on a user status?

Personally I don't use smarty*, but even I can see the benefits it
offers.

* only because I don't build web sites for clients, I build them for
one specific company and we have our own template system in-house.

-- 
Best regards,
 Richard Davey
 http://www.phpcommunity.org/wiki/296.html

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] smarty

2004-04-14 Thread Chris de Vidal
Kelly Hallman said:
 I don't recall anyone ever advancing the notion that Smarty turned PHP
 into something more than it was before. By definition it is merely a layer
 that makes your life as a developer easier. A tool!

Yeah but in my ignorance that's what I thought, and I realized I probably
was not alone.

 However, those of us who are seeing great benefit from the use of Smarty
 are not mere ignoramouses, and I feel that the implication being made is
 that we're not seeing what PHP can already do. This is false.

OK but I was an ignoramous and I believe there *are* others out there like
myself.

 The reason this is such a contentious issue, I think, is because the point
 being made--while correct, and note-worthy--is short-changing Smarty by
 calling it redundant. I feel that one's use of Smarty may indeed be
 redundant, that's easy to do. However, Smarty is not inherently redundant.
 Using Smarty redundantly does not make Smarty itself one bit redundant.

I said it was mostly, not completely redundant.  In the case of the cool
built-in functions you've got some advantages.  But I believe those could
also be (perhaps more effectively) implimented with other libraries.  It's
just a tool.

 To make that claim, you're dropping a pretty heavy dis on a lot of people
 who have invested a great deal of time, effort, and subsequently realized
 great benefits from Smarty and it's templating brethren. Not to mention
 all those who have devoted great effort in the development of these tools.

I believe it and most templating engines were written because many people
didn't know they had an alternative.  I could be wrong; if so, it is a
heavy dis.  Didn't mean it that way, so if I am wrong I humbly
apologize.

 I'm seriously not trying to sound harsh here, but do you think that by
 realizing you could structure your PHP code in such a way to mimic a basic
 Smarty template, you've now single-handedly debunked the purpose for all
 of this effort by so many avid PHP programmers? Seriously, now...!

Naww... I'd been using Smarty for several weeks now because I thought the
only alternative to spaghetti code was Smarty, but recently I realized
that it's not, and that simple example shows it.  I didn't realize I had
another alternative.

It's like this: Does your mother know you're stupid?  Either way you
answer, you're stupid.  If you don't realize you have another alternative
you're stuck.  I believe Smarty was written because people didn't realize
they had the other alternative.  If I am wrong, see above.

 Regardless of the merit of the point being made, I don't think that
 benefits anyone much. I'm sure when some guy came up with a metal knife,
 there was a dude there with a sharp rock saying, but this works too!
 Then the guy with the knife started using it to cut everything, while the
 rock required constant honing to remain sharp enough to do half the work.
 But the guy with the rock thought it was all he needed! I use a knife.

I see what you mean, but my point is PHP already *is* the knife: it
templates with about the same effort as Smarty.  At times less effort (in
which case I'd use native PHP), at times more (in which case I'd use
Smarty).

Anyway, thanks for the input.

/dev/idal

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] smarty

2004-04-14 Thread Chris de Vidal
pete M said:
 Think everyone is missing the point..
 the whole point of smarty is to take the presentation code away from the
 logic

No, I understood that point.  It's why I started using Smarty.  Take
another look at what I said:
http://marc.theaimsgroup.com/?l=php-generalm=108145205519710w=2

/dev/idal

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] smarty

2004-04-14 Thread Chris de Vidal
Richard Davey said:
 CdV I don't understand... how is this:
 [snip]
 CdV Better than this?
 CdV =
 CdV $result = mysql_query (SELECT * FROM users WHERE id =
 '.$_GET[id].');
 CdV $row_array = mysql_fetch_array ($result);
 CdV $name= $row_array[name];
 CdV $address = $row_array[address];
 CdV $state   = $row_array[state];
 CdV $include(template.tpl);
 CdV ---
 CdV html
 CdV body
 CdV Name: ?=$name;?br
 CdV Address: ?=$address;?br
 CdV State: ?=$state;?br
 CdV ...
 CdV ===

 Because you're injecting variables directly into your HTML, which some
 of the time might be ok - but what if the $row_array doesn't contain
 name ? You'll raise an Error Warning without first passing it
 through some kind of test (or function).

A good point.  Alternatively I could write error handling myself or
include a library/class.  This is where, in my opinion, Smarty shines, but
is not significantly different than other libraries/classes.

 You assume that the PHP short-tags are enabled (? ?) for
 echoing variables and while most the time they are, you shouldn't bank
 on it in code (incidentally, you don't need the trailing ; on the
 short-tag echos).

I was waiting for someone to ding this :-)  I have been used to using
?php echo $variable; ?.

 Sure - these things can be fixed easily, but then that isn't the point
 - if you think about it logically, anything Smarty can do, PHP can do
 too (well, duh! :)

 But what if you want to take your template and perform a bit more than
 just mere variable substitution on it? How about highlighting all
 words that match a search term, or applying logic to a display block
 based on a user status?

Another good point.  But by writing it myself or including some other
library/class I could have the same functionality.  There again, Smarty is
a great library, and I'll use it when I need it.

 Personally I don't use smarty*, but even I can see the benefits it
 offers.

Me too.  It's likely I'll use it in the future.

/dev/idal

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: Re[2]: [PHP] smarty

2004-04-14 Thread John W. Holmes
From: Richard Davey [EMAIL PROTECTED]

 Because you're injecting variables directly into your HTML, which some
 of the time might be ok - but what if the $row_array doesn't contain
 name ? You'll raise an Error Warning without first passing it
 through some kind of test (or function).

Only if you have error_reporting() set high. If you have a PHP templating
solution, you'd turn error_reporting() down when you included the PHP
templates so you didn't get a warning.

 You assume that the PHP short-tags are enabled (? ?) for
 echoing variables and while most the time they are, you shouldn't bank
 on it in code (incidentally, you don't need the trailing ; on the
 short-tag echos).

You're relying on web-server writable directories when you use Smarty. It's
all a trade-off.

  But what if you want to take your template and perform a bit more than
 just mere variable substitution on it? How about highlighting all
 words that match a search term, or applying logic to a display block
 based on a user status?

You can do this with output buffering and PHP functions. Smarty just
provides you a different interface.

?php start_highlight(); ?
Paragraph Text
?php end_highlight(); ?

vs.

{section type=highlight}
Paragraph Text
{/section}

Yeah, I know that's not quite the Smarty syntax, but you get the idea.
Smarty just provides an easy interface to a lot of these things. It's a
tool, like a lot of others have said. :)

---John Holmes...

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] smarty

2004-04-14 Thread Enrico Weigelt
* Chris de Vidal [EMAIL PROTECTED] [2004-04-14 10:30:53 -0400]:

snip
 So there are alternatives to what Smarty offers, but I also said I just
 see them [template engines] as another tool.  It's a tool; use it where

I can't agree here. 

Template engines (in the sense we're talking here - for separating 
presentation/layout from application logic in web-like application 
environments) should be much more than just a tool, they're better 
should be considered as a fundamental component in the whole environment,
as well as the application server, the frontend webserver (httpd),
database/storage or client.

The W3C tries to establish its own template engine - XSLT - (probably
the most powerful) in the web. Of course its a little bit too 
complicated and overdozed for many small applications and quite hard
to learn for non-programmers. So there're other, more simple, 
template engines out there, i.e. patTemplate/pTemplate.


cu
-- 
-
 Enrico Weigelt==   metux IT services

  phone: +49 36207 519931 www:   http://www.metux.de/
  fax:   +49 36207 519932 email: [EMAIL PROTECTED]
  cellphone: +49 174 7066481
-
   -- DSL-Zugang ab 0 Euro. -- statische IP -- UUCP -- Hosting --
-

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] smarty

2004-04-14 Thread Enrico Weigelt
* Chris de Vidal [EMAIL PROTECTED] [2004-04-14 11:33:56 -0400]:

snip
 Naww... I'd been using Smarty for several weeks now because I thought the
 only alternative to spaghetti code was Smarty, but recently I realized
 that it's not, and that simple example shows it.  I didn't realize I had
 another alternative.

Well, you should probably try patTemplate :)


cu
-- 
-
 Enrico Weigelt==   metux IT services

  phone: +49 36207 519931 www:   http://www.metux.de/
  fax:   +49 36207 519932 email: [EMAIL PROTECTED]
  cellphone: +49 174 7066481
-
   -- DSL-Zugang ab 0 Euro. -- statische IP -- UUCP -- Hosting --
-

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] smarty

2004-04-14 Thread Vicente Werner
mmm some points:

1st. Clarity. It's much more clear to me to take a look at a template and 
identify a subsituing variable when it's marked as something different like:
{$var} than the uglyness of ?=$var ? -and if you follo the recommended way: 
?php=$var ?

2nd. As other users pointed, error handling.

3th. Lack of temptation. If I start putting pure php code on my templates it 
wouldn't be long before half the application logic ends there, we'll know 
what's to code under tight schedules. Smarty by separating my presentation 
logic from my bussines logic helps me avoid spaghetti code.

Appart from the ton of small features that smarty gives you like caching, 
easyness to do popups, the variable modificators, etc..

-- 
__
Vicente Antonio Sánchez Werner ( [EMAIL PROTECTED] )
Fijo: +34-923185650 Movil: +34-66865
Director Depto Informática, Desarrollo y Seguridad Informática
Wap Comunicaciones S.L.
C/Guadalajara nº9-11
37003 Salamanca (España)
--

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] smarty

2004-04-14 Thread Chris de Vidal
Vicente Werner said:
 mmm some points:

 1st. Clarity. It's much more clear to me to take a look at a template and
 identify a subsituing variable when it's marked as something different
 like:
 {$var} than the uglyness of ?=$var ? -and if you follo the recommended
 way:
 ?php=$var ?

Tomay-toe, toh-mah-toe.

 2nd. As other users pointed, error handling.

Possibly.  I could also custom-build it or add it with other
libraries/classes.  Smarty has it built-in, making Smarty a great choice.

 3th. Lack of temptation. If I start putting pure php code on my templates
 it wouldn't be long before half the application logic ends there, we'll
 know what's to code under tight schedules. Smarty by separating my
 presentation logic from my bussines logic helps me avoid spaghetti code.

You must be disciplined in any case.  Smarty has loops and custom
functions and can even include real PHP.  You just have to be disciplined.

 Appart from the ton of small features that smarty gives you like caching,
 easyness to do popups, the variable modificators, etc..

Caching/popups/variable modifications can be easily added with native PHP
functions (that perhaps people aren't aware of) or with external
libraries/classes.  Smarty has them all under one roof, making it an
excellent choice -- when it's needed.

My point is that it isn't always needed, as I thought it was.  I'm sure
others believe it's their only choice.

/dev/idal

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: Re[2]: [PHP] smarty

2004-04-14 Thread Enrico Weigelt
* John W. Holmes [EMAIL PROTECTED] [2004-04-14 11:57:00 -0400]:

snip
 You're relying on web-server writable directories when you use Smarty. 
 It's all a trade-off.

This gets problematic in multi-user environments. You cant use mod_php
anylonger, instead you have to switch to slow cgi+suexec.

Okay, w/ metuxmpm this problem goes away - each vhost can get its 
own uid - but its not 100% stable yet (some rarely situations w/
recoursive requests seem to make MT problems)

   But what if you want to take your template and perform a bit more than
  just mere variable substitution on it? How about highlighting all
  words that match a search term, or applying logic to a display block
  based on a user status?
 
 You can do this with output buffering and PHP functions. Smarty just
 provides you a different interface.

Output Buffering is a bad hack.

The original branch of content-builder's base template system used this,
but I've completely removed this - now there's exactly one print call
at the very end of the page processing. If there have to be snippets
rendered separately, it goes directly into variables or the template-engine's
internal buffers (required when template processing run in a different
process or host)


cu
-- 
-
 Enrico Weigelt==   metux IT services

  phone: +49 36207 519931 www:   http://www.metux.de/
  fax:   +49 36207 519932 email: [EMAIL PROTECTED]
  cellphone: +49 174 7066481
-
   -- DSL-Zugang ab 0 Euro. -- statische IP -- UUCP -- Hosting --
-

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] smarty

2004-04-14 Thread Curt Zirzow

:0
* ^Subject: Re: smarty 
/dev/null

Curt
-- 
I used to think I was indecisive, but now I'm not so sure.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re[4]: [PHP] smarty

2004-04-14 Thread Richard Davey
Hello John,

Wednesday, April 14, 2004, 4:57:00 PM, you wrote:

JWH Only if you have error_reporting() set high. If you have a PHP templating
JWH solution, you'd turn error_reporting() down when you included the PHP
JWH templates so you didn't get a warning.

John I'm shocked - of all people I would expect you to be an advocate
of coding something that even E_ALL won't complain about.

JWH You can do this with output buffering and PHP functions. Smarty just
JWH provides you a different interface.

Isn't that the whole point of it? :) besides it's not just a different
interface - if you make a mistake you have a chance that smarty will
catch this and deal with it nicely for you. A pure PHP engine
(sic) will not, you get a function name wrong and the site will brake.

Sure.. you can code around it.. but then if you keep playing that
card, soon enough you've written your own Smarty replacement, which is
somewhat ironic, no?

-- 
Best regards,
 Richard Davey
 http://www.phpcommunity.org/wiki/296.html

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] smarty

2004-04-14 Thread pete M
Curt Zirzow wrote:
:0
* ^Subject: Re: smarty 
/dev/null

Curt


agreed

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Smarty Summary was Re: [PHP] smarty

2004-04-10 Thread Jochem Maas
Justin Patrin wrote:

Jochem Maas wrote:
...

Smarty does force that at all; you have to make the distinction and 
apply liberal self-restraint.
I meant 'does NOT force' - thinko!

...

PLEASE WORLD: GET BEHIND CSS, AND FREE CONTENT FROM STYLE ON THE CLIENT.
why because it allows the structrully mark-uped to be display more 
flexibly, for diff. display, aural readers, braille etc. removing the 
styling definitions it also allows you to specify different markup.


I want to. I so want to, but I can never get it to make the layout as I 
want it. I want to take a div and make it vertically or horizontally 
be practical - if you need to vertical align something and can't get it 
to work another way use a table.

I CSS site that I found really inspiring is http://www.csszengarden.com/
if you really 'want to' then take the time to read it and view all the 
styles (well not ness. all 247) - take a look at the HTML (and the CSS 
file for each style), maybe have a go at it yourself.

centered in another divif you figure out how to do it with dynamic 
try to let go of the assumption that you can control the display of your 
pages (think of the all the platform/hardware/software/user-settings/etc 
 combinations there are.) - you can only guide it. one of the founding 
ideas of the 'webpage' if that the manner in which it is displayed is 
upto the user (braille/speech/mobile/PC/Barney).

also attempt a site contruction by first creating a bare bones text only 
site with proper markup (P,H tags etc. prefer XHTML over HTML), the see 
what you can add. (have a look at the effect is of using different 
DOC-TYPEs)

sizes that is easy and works on all the major browsers, let me know. 
I've tried for hours, looks on I don't know how many websites, and I 
still couldn't do it. I went back to tables because it's just so easy. 
CSS makes my life very hard...it doesn't seem to have the basics needed 
to create an entire layout.
er but it really does (and the trick is to). not to worry I have been 
hacking css for about 3 years now, in the beginning it was even worse - 
support is getting better which means documentation often more closely 
ressembles truth ;-)

Make Mozilla/Opera part of your testing kit - they support CSS better 
(they are not 3+ years old like IE6).

instead of approaching it from the view of a print designer - ie fixed, 
static layout - assume the layout is a liquid 
(http://www.google.com/search?sourceid=navclientie=UTF-8oe=UTF-8q=liquid+design)

to be honest - in this game you really have to study something to truely 
get a grip on it. I mean, how many scripts have you poured over, how 
many hours with just one of those scripts to get it to play just right? 
 CSS is no different.

That said, I do use lots of CSS for styling (font sizes, colors, images, 
printable pages, etc.), but fill-page styling via CSS is just beyond my 
reach.
dumping all those style definitions in a seperate file in a good start.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Smarty Summary was Re: [PHP] smarty

2004-04-09 Thread Justin Patrin
Jochem Maas wrote:

Chris de Vidal wrote:

Jochem Maas said:

1. 'Template Engine' - you can justifyably call PHP a template engine


Correct.  Seems that Smarty is, for the most part, redundant (see my last
post called PHP makes a great templating engine (Was: smarty)).
I was not intending to pronounce Smarty redundant; on the contrary if 
anything - but thats not the point...


but I think calling Smarty a template engine confuses the issue - it
would be clearer call it something like 'Presentation Component' which
encapsulates output caching, output string transformation, markup
generation, presentation logic security  seperation of (code  possibly
human) tasks. viewing it as a component means viewing it as a tool,
tools are used when appropriate and according to their capabilities and
the scope of the job at hand. in principle a sizeable proportion of all
the.


Tool.  Look at it as just another tool.  I was seeing it as a must have
because I was somewhat ignorant of PHP's native capabilities.  It adds
complexity and does indeed slow down your program (the Smarty class must
load on every page) so keep those in mind.  On the other hand, you're


the Smarty core is smaller than, for example, PEAR::QuickForm (if you 
use all the plugins its about 40% larger) - and PEAR::QuickForm is 
usually used with a Renderer (e.g. Smarty!!), think of it like this: how 
much do you charge per hour, what does an extra CPU cost  how much, if 
any, time does Smarty save you. (besides which I think its quite easy to 
develop something in Smarty which does what QuickForm does but more 
transparently and with alot less hassle - IMHO).

Code is code; it might not be perfect but it might scratch an itch.

almost forced to separate business and presentation and you gain caching


Smarty does force that at all; you have to make the distinction and 
apply liberal self-restraint.

(though native PHP options or Zend are available).  So it's a weighty
decision.  But it is a good tool.


Realise that Smarty (usually) only re-compiles the template if it 
changes. The compiled template are full of generated PHP - there is 
little overhead in including that.

if you use a native PHP option then:
a, what is Smarty? (not important!)
b, what are the chances that your output code/module/class/etc will
not employ similar solutions to something like Smarty? because broadly 
speaking



3. 'Lock In'


I believe Lock In is a big problem unless you document well.  For
instance, my supervisor is probably going to choose ASP.NET (don't ask
why) for our next project.  But all along, I plan to document it well in
case we hit a stumbling block.  With a bit of effort and the source 
code I
can port it to PHP.  I've even toyed with the idea of keeping a
fully-functional copy written in PHP while he's working in ASP.NET ;-) 
But I've got better things to do.


Limitations are often purely percieved rather than actual


I believe that's why I chose Smarty for my last project.  I thought PHP
limited me to keeping business logic mixed with presentation logic, but
it's hardly the case.


and funnily enough Smarty is actually a pretty good example of a 
possible PHP based solution to the problem logic seperation.

When you consider that it's just another tool in your box, it works 
well. It's not the only way to let designers design and programmers 
program
(Jochem is a big believer in CSS for that).  Just think of it as another


PLEASE WORLD: GET BEHIND CSS, AND FREE CONTENT FROM STYLE ON THE CLIENT.
why because it allows the structrully mark-uped to be display more 
flexibly, for diff. display, aural readers, braille etc. removing the 
styling definitions it also allows you to specify different markup.
I want to. I so want to, but I can never get it to make the layout as I 
want it. I want to take a div and make it vertically or horizontally 
centered in another divif you figure out how to do it with dynamic 
sizes that is easy and works on all the major browsers, let me know. 
I've tried for hours, looks on I don't know how many websites, and I 
still couldn't do it. I went back to tables because it's just so easy. 
CSS makes my life very hard...it doesn't seem to have the basics needed 
to create an entire layout.

That said, I do use lots of CSS for styling (font sizes, colors, images, 
printable pages, etc.), but fill-page styling via CSS is just beyond my 
reach.

Ever written a print version of a page? why bother when all you need do 
  is specify alternative stylesheet(s) to use for print media.

Ever heard you page say 'IMAGE' 'TABLE'  'DATA CELL' 50 odd times as a 
blind persons screen reader trys to make sense of your pretty new 
data-driven creation... where the f*** is the menu?! did you know there 
is even an extensive specification for markup of aural media (e.g. tone 
of voice, male/female, speed etc etc)

In my little world I have officially declared a Good Thing. of course
it leaves the problem of how to manage all those stylesheets 

RE: [PHP] smarty

2004-04-08 Thread Vincent DUPONT

Does anyone have a 'good' tutorial about Smarty. The one available on smarty.php.net 
is really basic...


Vincent


-Original Message-
From: Robert Cummings [mailto:[EMAIL PROTECTED]
Sent: jeudi 8 avril 2004 4:02
To: Kelly Hallman
Cc: PHP-General
Subject: Re: [PHP] smarty


On Wed, 2004-04-07 at 21:35, Kelly Hallman wrote:
 Apr 8 at 10:26am, Justin French wrote:
  PHP itself is a great templating language :)
  h1?=$title?/h1
  table
  ? foreach($staff as $person): ?tr
  td?=$person['firstname']? ?=$person['surname']?/td
  td?=$person['role']?/td
  td?=$person['phone']?/td
  tda href='mailto:?=$person['email']?'?=$person['email']?/td
  /tr? endforeach; ?/table
 
 Uhhh, yeah--that's not a templating, that's called spaghetti code :)
 
 You get the concept. Smarty, as you know, basically takes a Smarty
 template and writes PHP code similar to what you've done above, then
 writes out the .php file, and includes it when you render your template.
 So you'd get nearly the same effect by writing the PHP as a separate file
 and including it as your last step, and it acts as your display logic.
 
 That may be acceptable to you, as a PHP programmer. If you're the only one
 who ever needs to modify your templates then that's great, more power to
 you. I'm sure that you would have no problem having many levels of nesting
 all over the place and not screwing anything up. So be it. But that's you.
 
 I guarantee another person not as adept at PHP will screw that code up,
 and there is less potential for that with a Smarty template. If you know
 PHP as well as yourself, it should be plain to see how Smarty is just a
 wrapper over PHP that makes templates easier to build and maintain.
 For a designer or non-coder, Smarty will be easier to learn than PHP.
  
 Unless your needs never exceed the very basics like you have demonstrated
 above, you'll be hosed when another person needs to modify your template.  
 Which goes back to a templating truism never in dispute: if this is all
 you want templating for, it's six of one, half a dozen of the other.
 
 However, there are practical limitations on what you can easily accomplish
 with this approach, and Smarty addresses those issues. And you're worse
 off if you invest a lot into building your sites this way, and then
 realize you need some better templating strategies later.
 
  You can still separate your logic from your presentation, template 
  designers can still use quick, simple tags to include code, and the 
  upside is that people familiar with PHP don't need to learn ANOTHER 
  language (that's what Smarty is) -- they can dive straight in.
 
 You can consider it it's own language, but really it's more like PHP with
 different formatting. Which is why it's different than what you're doing
 above--it's designed to facilitate templating. Your method is just poking
 in variables and PHP into inline'd HTML. It works, but you're missing some
 of the power of Smarty if you think that's all it's good for.
 
  The question is, do you want to give your templater designers full 
  access to the power of PHP, or not.
 
 In other words: are your template designers already good PHP programmers?
 It's not just hype, it solves real problems, even if you don't have them.

Smarty is a bit of a hack too... why do I need to declare my templates
within the PHP code? If I'm an HTML designer I'd like to create a new
page, include templates, use some data that's been made available and
have it all in the template. I sure as heck wouldn't want to have joe
programmer edit the main page, add support for importing my template.
This is the thing that bugs me about Smarty, its still got that hanging
dependency. And it's still got to include all those templates within the
source code.

InterJinn is superior in this respect. You use XML tags to import other
templates, you use XML tags to load modules and components, and you use
XML tags to do almost any kind of expansion you want. Of course, you can
go ahead and use something else, InterJinn provides the ability to plug
in custom compilers. InterJinn compiles to PHP code, includes are
INCLUDED at compile time not at run time. So given this scheme anyone
working on the HTML is already familiar with the syntax... hard to go
wrong with:

jinn:template path=topnav.template/

Hell you can even overload HTML tags. Not only that but Interjinn allows
recursive includes of templates and source files, and these includes can
be relative to the outer nested template or source file. Furthermore,
there's nothing forcing the use of the InterJinn application layer so
InterJinn can be used entirely for it's templating features, in which
case it provides a faster resulting PHP page than using PHP include().

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework

  1   2   >