Re: [PHP] Re: Question about template systems

2009-03-05 Thread Nathan Nobbe
On Mar 5, 2009, at 4:16 AM, Robert Cummings   
wrote:



On Thu, 2009-03-05 at 03:08 -0800, Michael A. Peters wrote:

Robert Cummings wrote:



function hiddenInput($document,$name,$value) {
   $input = $document->createElement("input");
   $input->setAttribute("type","hidden");
   $input->setAttribute("name",$name);
   $input->setAttribute("value",$value);
   return($input);
   }



imo, I'd much rather have the simple syntax of phacade, rather than  
use the Dom Api directly; if I were using this approach in practice.



Does that answer your question?


That was what I thought.

Cheers,
Rob.


Is there a reason I shouldn't be doing it that way?


I didn't say you shouldn't. It's just expensive on every page  
request to

regenerate a document node by node. it also strikes me as tedious :/



it's way less tedious if you curb the syntax, which was my motivation  
for the system I posted earlier.  The idea was to make it feel just  
like writing xhtml, but really it's just php code.


it's definately an expensive approach, but at least using native code  
for most of the heavy lifting should make it way faster than a  
straight php solution (using the same approach).


-nathan

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



Re: [PHP] Re: Question about template systems

2009-03-05 Thread Michael A. Peters

Robert Cummings wrote:



Is there a reason I shouldn't be doing it that way?


I didn't say you shouldn't. It's just expensive on every page request to
regenerate a document node by node. it also strikes me as tedious :/


It's definitely tedious - but I end up writing functions that do the 
tedious stuff when I can.


Paragraph nodes that include several children (span nodes and anchor 
nodes etc.) are the worst. Not too bad though once you get use to doing 
it that way. Paragraphs with too many spans and links are usually bad 
design anyway, so it encourages you to find a way to get your content 
point across in a better fashion ;)


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



Re: [PHP] Re: Question about template systems

2009-03-05 Thread Robert Cummings
On Thu, 2009-03-05 at 03:08 -0800, Michael A. Peters wrote:
> Robert Cummings wrote:
> 
>  >>
>  >> function hiddenInput($document,$name,$value) {
>  >> $input = $document->createElement("input");
>  >> $input->setAttribute("type","hidden");
>  >> $input->setAttribute("name",$name);
>  >> $input->setAttribute("value",$value);
>  >> return($input);
>  >> }
>  >>
>  >> Does that answer your question?
>  >
>  > That was what I thought.
>  >
>  > Cheers,
>  > Rob.
> 
> Is there a reason I shouldn't be doing it that way?

I didn't say you shouldn't. It's just expensive on every page request to
regenerate a document node by node. it also strikes me as tedious :/

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] Re: Question about template systems

2009-03-05 Thread Michael A. Peters

Robert Cummings wrote:

>>
>> function hiddenInput($document,$name,$value) {
>> $input = $document->createElement("input");
>> $input->setAttribute("type","hidden");
>> $input->setAttribute("name",$name);
>> $input->setAttribute("value",$value);
>> return($input);
>> }
>>
>> Does that answer your question?
>
> That was what I thought.
>
> Cheers,
> Rob.

Is there a reason I shouldn't be doing it that way?

The reasons I like it so much, even though it requires more lines to do 
the same thing -


1) Mixing html and php is really ugly and difficult to maintain - 
sometimes even a week after I write mixed code I have issues reading it, 
especially when mixing html and php inside a loop. It's much easier to 
track down a missing } this way.


2) Let's me easily translate to valid html 4.01 for clients that don't 
accept xml+html


3) So far I haven't (yet) found an xss attack that works with zero input 
validation. Everything I've tried - even the most bizarre filter dodging 
tricks - seems to be nicely turned into a text node. For that reason 
alone it seems worth it, but that's a side effect of me choosing to do 
things that way. A very pleasant one, though.



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



Re: [PHP] Re: Question about template systems

2009-03-05 Thread Robert Cummings
On Thu, 2009-03-05 at 02:04 -0800, Michael A. Peters wrote:
> Robert Cummings wrote:
> > On Wed, 2009-03-04 at 18:01 -0800, Michael A. Peters wrote:
> >> Robert Cummings wrote:
> >>> On Wed, 2009-03-04 at 15:21 -0800, Michael A. Peters wrote:
>  Robert Cummings wrote:
> 
> > To punt what is repeated over and over during runtime to a single
> > compilation phase when building the template target. To simplify the use
> > of parameters so that they can be used in arbitrary order with default
> > values. To allow for the encapsulation of complex content in tag format
> > that benefits from building at compile time and from being encapsulated
> > in custom tags that integrate well with the rest of the HTML body.
>  I can't speak to those (and I have no opinion on template systems having 
>  never used any of them.
> 
> > To
> > remove the necessaity of constantly moving in and out of PHP tags.
>  php does not require that you constantly move in and out of PHP tags.
>  There's at least one and possibly several pure php solutions that allow 
>  one to never write a line of html but get beautiful dynamic html output.
> >>> It doesn't require, but if you're not moving between them, then you're
> >>> probably echoing your HTML, and that can be a maintenance nightmare.
> >> echoing html involves mixing html and php.
> >> Using an XML class (like DOMDocument) to build the document does not.
> > 
> > So you punt the entire rendering of the HTML content to run-time
> > execution one node at a time?
> > 
> > Cheers,
> > Rob.
> 
> This is what I do.
> I create the nodes as needed and add them to the parent nodes when I'm 
> done with them - and when the document is finished, add the various 
> content nodes to the body node, body/head nodes to html node, and then 
> use saveXML(); to get the output as x(ht)ml to send to the browser.
> 
> If that's what you described then yes. Otherwise, then no - it's not.
> 
> some example, IE to build my form -
> 
> $xmlForm = $myxhtml->createElement("form");
> $xmlForm->setAttribute("id","records");
> $xmlForm->setAttribute("method","post");
> if ($multipart > 0) {
> $xmlForm->setAttribute("enctype","multipart/form-data");
> }
> $xmlForm->setAttribute("action",$formaction);
> $xmlForm->setAttribute("onsubmit",$onsubmit);
> $hiddenDiv = $myxhtml->createElement("div");
> $hiddenDiv->setAttribute("id","hidden_inputs");
> $hinput=hiddenInput($myxhtml,"coord_pref",$coord_pref);
> $hinput->setAttribute("id","coord_pref");
> $hiddenDiv->appendChild($hinput);
> $hinput=hiddenInput($myxhtml,"alt_pref",$alt_pref);
> $hiddenDiv->appendChild($hinput);
> $hinput=hiddenInput($myxhtml,"temp_pref",$temp_pref);
> $hiddenDiv->appendChild($hinput);
> 
> // etc ..
> 
> if(isset($imgref)) {
> $hinput=hiddenInput($myxhtml,"imgref",$imgref);
> $hiddenDiv->appendChild($hinput);
> $hasimage=1;
> }
> 
> if ($museum == 1) {
> if (isset($validarray['museum'])) {
>require('xml_record_museum.inc');
>} else {
>$hinput=hiddenInput($myxhtml,"museumid",$rcd_musid);
>$hinput->setAttribute("id","museumid");
>$hiddenDiv->appendChild($hinput);
>$hinput=hiddenInput($myxhtml,"museum_name",$rcd_musnum);
>$hinput->setAttribute("id","museum_name");
>$hiddenDiv->appendChild($hinput);
>}
> }
> if ($editrecord == 1) {
> $hinput=hiddenInput($myxhtml,"recordid",$record);
> $hiddenDiv->appendChild($hinput);
> }
> if (isset($validarray['species'])) {
> require('xml_record_species.inc');
> } else {
> $hinput=hiddenInput($myxhtml,"herpid",$rcd_species);
> $hinput->setAttribute("id","herpid");
> $hiddenDiv->appendChild($hinput);
> }
> 
> ...
> 
> $xmlForm->appendChild($hiddenDiv);
> $submitDiv = $myxhtml->createElement("div");
> $submitDiv->setAttribute("id","submitdiv");
> $submitDiv->setAttribute("class","formFloat");
> 
> $submitInput = $myxhtml->createElement("input");
> $submitInput->setAttribute("type","submit");
> $submitInput->setAttribute("id","submit");
> $submitInput->setAttribute("name","submit");
> $submitInput->setAttribute("value",$submit_val);
> $submitDiv->appendChild($submitInput);
> 
> $xmlForm->appendChild($submitDiv);
> $contentDiv->appendChild($xmlForm);
> 
> The various requires are files that create various parts of the form. 
> They are in individual separate files because some of them are used in 
> other forms and I don't like to have replicated code that is 
> functionally equivalent.
> 
> hiddenInput is a simple function I wrote that returns an input node of 
> type hidden - which I can (when needed, IE if I want to add an id tag 
> for javascript hook) I can continue to modify.
> 
> function hiddenInput($document,$name,$value) {
> $input = $document->createElement("input");
> $input->setAttribute("type","hidden");
> $input->setAttribute("name",$name);
> $input->setAttribute("value",$value);
>

Re: [PHP] Re: Question about template systems

2009-03-05 Thread Michael A. Peters

Robert Cummings wrote:

On Wed, 2009-03-04 at 18:01 -0800, Michael A. Peters wrote:

Robert Cummings wrote:

On Wed, 2009-03-04 at 15:21 -0800, Michael A. Peters wrote:

Robert Cummings wrote:


To punt what is repeated over and over during runtime to a single
compilation phase when building the template target. To simplify the use
of parameters so that they can be used in arbitrary order with default
values. To allow for the encapsulation of complex content in tag format
that benefits from building at compile time and from being encapsulated
in custom tags that integrate well with the rest of the HTML body.
I can't speak to those (and I have no opinion on template systems having 
never used any of them.



To
remove the necessaity of constantly moving in and out of PHP tags.

php does not require that you constantly move in and out of PHP tags.
There's at least one and possibly several pure php solutions that allow 
one to never write a line of html but get beautiful dynamic html output.

It doesn't require, but if you're not moving between them, then you're
probably echoing your HTML, and that can be a maintenance nightmare.

echoing html involves mixing html and php.
Using an XML class (like DOMDocument) to build the document does not.


So you punt the entire rendering of the HTML content to run-time
execution one node at a time?

Cheers,
Rob.


This is what I do.
I create the nodes as needed and add them to the parent nodes when I'm 
done with them - and when the document is finished, add the various 
content nodes to the body node, body/head nodes to html node, and then 
use saveXML(); to get the output as x(ht)ml to send to the browser.


If that's what you described then yes. Otherwise, then no - it's not.

some example, IE to build my form -

$xmlForm = $myxhtml->createElement("form");
$xmlForm->setAttribute("id","records");
$xmlForm->setAttribute("method","post");
if ($multipart > 0) {
   $xmlForm->setAttribute("enctype","multipart/form-data");
   }
$xmlForm->setAttribute("action",$formaction);
$xmlForm->setAttribute("onsubmit",$onsubmit);
$hiddenDiv = $myxhtml->createElement("div");
$hiddenDiv->setAttribute("id","hidden_inputs");
$hinput=hiddenInput($myxhtml,"coord_pref",$coord_pref);
$hinput->setAttribute("id","coord_pref");
$hiddenDiv->appendChild($hinput);
$hinput=hiddenInput($myxhtml,"alt_pref",$alt_pref);
$hiddenDiv->appendChild($hinput);
$hinput=hiddenInput($myxhtml,"temp_pref",$temp_pref);
$hiddenDiv->appendChild($hinput);

// etc ..

if(isset($imgref)) {
   $hinput=hiddenInput($myxhtml,"imgref",$imgref);
   $hiddenDiv->appendChild($hinput);
   $hasimage=1;
   }

if ($museum == 1) {
   if (isset($validarray['museum'])) {
  require('xml_record_museum.inc');
  } else {
  $hinput=hiddenInput($myxhtml,"museumid",$rcd_musid);
  $hinput->setAttribute("id","museumid");
  $hiddenDiv->appendChild($hinput);
  $hinput=hiddenInput($myxhtml,"museum_name",$rcd_musnum);
  $hinput->setAttribute("id","museum_name");
  $hiddenDiv->appendChild($hinput);
  }
   }
if ($editrecord == 1) {
   $hinput=hiddenInput($myxhtml,"recordid",$record);
   $hiddenDiv->appendChild($hinput);
   }
if (isset($validarray['species'])) {
   require('xml_record_species.inc');
   } else {
   $hinput=hiddenInput($myxhtml,"herpid",$rcd_species);
   $hinput->setAttribute("id","herpid");
   $hiddenDiv->appendChild($hinput);
   }

...

$xmlForm->appendChild($hiddenDiv);
$submitDiv = $myxhtml->createElement("div");
$submitDiv->setAttribute("id","submitdiv");
$submitDiv->setAttribute("class","formFloat");

$submitInput = $myxhtml->createElement("input");
$submitInput->setAttribute("type","submit");
$submitInput->setAttribute("id","submit");
$submitInput->setAttribute("name","submit");
$submitInput->setAttribute("value",$submit_val);
$submitDiv->appendChild($submitInput);

$xmlForm->appendChild($submitDiv);
$contentDiv->appendChild($xmlForm);

The various requires are files that create various parts of the form. 
They are in individual separate files because some of them are used in 
other forms and I don't like to have replicated code that is 
functionally equivalent.


hiddenInput is a simple function I wrote that returns an input node of 
type hidden - which I can (when needed, IE if I want to add an id tag 
for javascript hook) I can continue to modify.


function hiddenInput($document,$name,$value) {
   $input = $document->createElement("input");
   $input->setAttribute("type","hidden");
   $input->setAttribute("name",$name);
   $input->setAttribute("value",$value);
   return($input);
   }

Does that answer your question?

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



Re: [PHP] Re: Question about template systems

2009-03-05 Thread Robert Cummings
On Wed, 2009-03-04 at 21:42 -0700, Nathan Nobbe wrote:
> On Wed, Mar 4, 2009 at 7:01 PM, Michael A. Peters  wrote:
>
> > echoing html involves mixing html and php.
> > Using an XML class (like DOMDocument) to build the document does not.
> 
> 
> ive actually written a little templating system which subclasses
> SimpleXMLElement to achieve just that, take a peak at the syntax if you like
> (any feedback appreciated),
> 
> http://nathan.moxune.com/phacadeDemo/
> 
> the syntax toward the bottom is what i really liked when i was starting
> out.  the demo page is about as far as i got w/ it, though.  what i ended up
> not liking about it, is how its joined at the hip w/ xml.  suppose i want to
> template other things,.. css, js, php all come to mind.
> 
> i could do that w/ pure php, and im sure any of these other systems such as
> smarty could let you template things beyond a subset of xml.  what i like
> about this blitz module, and Rob's TemplateJinn, is an additional emphasis
> on performance.

That was one of the reasons I wrote the TemplateJinn parser from
scratch. It isn't dependent on XML. The custom tag aspect (only one
part) of it uses XML-like tag syntax, but it does not require that an
entire document be XML compliant nor even XML-like at all. This allows
the tags to be applied to older non-compliant documents, partial
documents, non tag documents, etc.

> the other thing that i cant understand in general about templating is the
> whole notion of making things easier for so-called "designers", ui folks or
> w/e, who arent used to 'code'.  in my personal experience, i have yet to see
> anyone actually doing that right, or anything close to it in a real
> environment.  im not trying to say there is one way and only one way to use
> a templating system, but im just saying that is a halmark benefit, which i
> dont think ive ever seen in practice..  what i see is programmers using them
> b/c they feel its hepling them separate presentation and logic.

I've had non programmers use my template engine, and they've not had a
problem. That doesn't mean to say it wasn't primarily developed for my
own use, but having a tag structure makes it fairly easy for anyone
using tags to understand.

> that said, i think folks really should look at what templating solutions are
> doing or can do in their environment.  i dont know, most templating systems
> look pretty similar to me from a distance, smarty & savant look
> fundamentally similar.  you have a class which you populate with data, and
> then those are mapped into placeholders in template files.  the rest of the
> differences seem skin deep to me, but if im missing something, id love to
> know.

There are different philosophies for how template engines work. For
instance Smarty uses a push system-- you initialize the template, assign
variable values, and smarty pushes the values to the template, then
returns the final content. TemplateJinn generally works the other way...
the template declares one or more modules (or makes use of a pre-loaded
module), the template includes tags that pull data from the module.
Since it's compiled to the final page, or PHP source that would be
included, then the data is pulled at run-time and the need for the
template processor is removed at run-time. TemplateJinn can work the
other way also... but I find it more natural for the template to declare
what it wants and to pull data from the module than the other way
around.

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] Re: Question about template systems

2009-03-05 Thread Robert Cummings
On Wed, 2009-03-04 at 18:01 -0800, Michael A. Peters wrote:
> Robert Cummings wrote:
> > On Wed, 2009-03-04 at 15:21 -0800, Michael A. Peters wrote:
> >> Robert Cummings wrote:
> >>
> >>> To punt what is repeated over and over during runtime to a single
> >>> compilation phase when building the template target. To simplify the use
> >>> of parameters so that they can be used in arbitrary order with default
> >>> values. To allow for the encapsulation of complex content in tag format
> >>> that benefits from building at compile time and from being encapsulated
> >>> in custom tags that integrate well with the rest of the HTML body.
> >>
> >> I can't speak to those (and I have no opinion on template systems having 
> >> never used any of them.
> >>
> >>> To
> >>> remove the necessaity of constantly moving in and out of PHP tags.
> >> php does not require that you constantly move in and out of PHP tags.
> >> There's at least one and possibly several pure php solutions that allow 
> >> one to never write a line of html but get beautiful dynamic html output.
> > 
> > It doesn't require, but if you're not moving between them, then you're
> > probably echoing your HTML, and that can be a maintenance nightmare.
> 
> echoing html involves mixing html and php.
> Using an XML class (like DOMDocument) to build the document does not.

So you punt the entire rendering of the HTML content to run-time
execution one node at a time?

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] Re: Question about template systems

2009-03-04 Thread Nathan Nobbe
On Wed, Mar 4, 2009 at 7:01 PM, Michael A. Peters  wrote:

> Robert Cummings wrote:
>
>> On Wed, 2009-03-04 at 15:21 -0800, Michael A. Peters wrote:
>>
>>> Robert Cummings wrote:
>>>
>>>  To punt what is repeated over and over during runtime to a single
 compilation phase when building the template target. To simplify the use
 of parameters so that they can be used in arbitrary order with default
 values. To allow for the encapsulation of complex content in tag format
 that benefits from building at compile time and from being encapsulated
 in custom tags that integrate well with the rest of the HTML body.

>>>
>>> I can't speak to those (and I have no opinion on template systems having
>>> never used any of them.
>>>
>>>  To
 remove the necessaity of constantly moving in and out of PHP tags.

>>> php does not require that you constantly move in and out of PHP tags.
>>> There's at least one and possibly several pure php solutions that allow
>>> one to never write a line of html but get beautiful dynamic html output.
>>>
>>
>> It doesn't require, but if you're not moving between them, then you're
>> probably echoing your HTML, and that can be a maintenance nightmare.
>>
>
> echoing html involves mixing html and php.
> Using an XML class (like DOMDocument) to build the document does not.


ive actually written a little templating system which subclasses
SimpleXMLElement to achieve just that, take a peak at the syntax if you like
(any feedback appreciated),

http://nathan.moxune.com/phacadeDemo/

the syntax toward the bottom is what i really liked when i was starting
out.  the demo page is about as far as i got w/ it, though.  what i ended up
not liking about it, is how its joined at the hip w/ xml.  suppose i want to
template other things,.. css, js, php all come to mind.

i could do that w/ pure php, and im sure any of these other systems such as
smarty could let you template things beyond a subset of xml.  what i like
about this blitz module, and Rob's TemplateJinn, is an additional emphasis
on performance.

the other thing that i cant understand in general about templating is the
whole notion of making things easier for so-called "designers", ui folks or
w/e, who arent used to 'code'.  in my personal experience, i have yet to see
anyone actually doing that right, or anything close to it in a real
environment.  im not trying to say there is one way and only one way to use
a templating system, but im just saying that is a halmark benefit, which i
dont think ive ever seen in practice..  what i see is programmers using them
b/c they feel its hepling them separate presentation and logic.

that said, i think folks really should look at what templating solutions are
doing or can do in their environment.  i dont know, most templating systems
look pretty similar to me from a distance, smarty & savant look
fundamentally similar.  you have a class which you populate with data, and
then those are mapped into placeholders in template files.  the rest of the
differences seem skin deep to me, but if im missing something, id love to
know.

sorry for the rant,

-nathan


Re: [PHP] Re: Question about template systems

2009-03-04 Thread Michael A. Peters

Robert Cummings wrote:

On Wed, 2009-03-04 at 15:21 -0800, Michael A. Peters wrote:

Robert Cummings wrote:


To punt what is repeated over and over during runtime to a single
compilation phase when building the template target. To simplify the use
of parameters so that they can be used in arbitrary order with default
values. To allow for the encapsulation of complex content in tag format
that benefits from building at compile time and from being encapsulated
in custom tags that integrate well with the rest of the HTML body.


I can't speak to those (and I have no opinion on template systems having 
never used any of them.



To
remove the necessaity of constantly moving in and out of PHP tags.

php does not require that you constantly move in and out of PHP tags.
There's at least one and possibly several pure php solutions that allow 
one to never write a line of html but get beautiful dynamic html output.


It doesn't require, but if you're not moving between them, then you're
probably echoing your HTML, and that can be a maintenance nightmare.


echoing html involves mixing html and php.
Using an XML class (like DOMDocument) to build the document does not.




To
speed up a site.

I'm curious about that one, how so?


What need not be rendered at runtime because it was rendered at compile
time saves that exact amount of time per page. When you include your
header, include your footer, include your sidepanel, etc... these are
all run-time hits. Primary navigation, secondary navigation, top bar
navigation, etc etc. These can all be pre-rendered and pre-rendered
contextually for each page to indicate which menu item corresponds to
the current page. Here's what I do for a menu:



Thanks!

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



Re: [PHP] Re: Question about template systems

2009-03-04 Thread Robert Cummings
On Wed, 2009-03-04 at 15:21 -0800, Michael A. Peters wrote:
> Robert Cummings wrote:
> 
> > 
> > To punt what is repeated over and over during runtime to a single
> > compilation phase when building the template target. To simplify the use
> > of parameters so that they can be used in arbitrary order with default
> > values. To allow for the encapsulation of complex content in tag format
> > that benefits from building at compile time and from being encapsulated
> > in custom tags that integrate well with the rest of the HTML body.
> 
> 
> I can't speak to those (and I have no opinion on template systems having 
> never used any of them.
> 
> > To
> > remove the necessaity of constantly moving in and out of PHP tags.
> 
> php does not require that you constantly move in and out of PHP tags.
> There's at least one and possibly several pure php solutions that allow 
> one to never write a line of html but get beautiful dynamic html output.

It doesn't require, but if you're not moving between them, then you're
probably echoing your HTML, and that can be a maintenance nightmare.

> > To
> > speed up a site.
> 
> I'm curious about that one, how so?

What need not be rendered at runtime because it was rendered at compile
time saves that exact amount of time per page. When you include your
header, include your footer, include your sidepanel, etc... these are
all run-time hits. Primary navigation, secondary navigation, top bar
navigation, etc etc. These can all be pre-rendered and pre-rendered
contextually for each page to indicate which menu item corresponds to
the current page. Here's what I do for a menu:













That's how I do menus, the tags and CSS is all then generated at compile
time. The match active regex is run at compile time against the page
being generated. The only thing that gets executed at run-time is
userIsLoggedIn() and that determines if the menu item is displayed, but
all the tags and CSS classes have already been pre-generated from this
very simple declaration. Similarly I have tags for embedding media,
images, etc. When I include an image tag, at compile time the width and
height of the image are determined and expanded into the HTML  tag.
There's lots of things developers do that costs them on every page load.
I punt the unnecessary stuff to the compile stage. For some pages, ones
that don't require any PHP logic, I can output a static HTML page that
never invokes the PHP parser, all with the same look and feel built at
compile time.

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] Re: Question about template systems

2009-03-04 Thread Michael A. Peters

Robert Cummings wrote:



To punt what is repeated over and over during runtime to a single
compilation phase when building the template target. To simplify the use
of parameters so that they can be used in arbitrary order with default
values. To allow for the encapsulation of complex content in tag format
that benefits from building at compile time and from being encapsulated
in custom tags that integrate well with the rest of the HTML body.



I can't speak to those (and I have no opinion on template systems having 
never used any of them.



To
remove the necessaity of constantly moving in and out of PHP tags.


php does not require that you constantly move in and out of PHP tags.
There's at least one and possibly several pure php solutions that allow 
one to never write a line of html but get beautiful dynamic html output.



To
speed up a site.


I'm curious about that one, how so?

-=-=-=-

And I've got a question.
Part of my page involves dynamically generated JavaScript.
The JavaScript will rarely change but it will change. By having php 
generate it, when my database is updated the js automatically will be 
too (yes I give the no-cache headers when sending the js. Actually I 
allow it to be cached for a day.)


Switching between php and JavaScript really sucks - moreso than 
switching between php and html as it is much easier to get lost in which 
language mode you are in.


Anyone know of a slick way to dynamically create javascript with php?

One thought I had - if there was an xml way to describe javascript and a 
filter to then create the actual javascript from the xml, I could create 
the js as xml and run it through the filter when sent to the browser.


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



Re: [PHP] Re: Question about template systems

2009-03-04 Thread Robert Cummings
On Wed, 2009-03-04 at 12:15 -0700, Nathan Nobbe wrote:
> On Wed, Mar 4, 2009 at 11:51 AM, Robert Cummings wrote:
> 
> > On Wed, 2009-03-04 at 12:46 -0600, Shawn McKenzie wrote:
> > > Robert Cummings wrote:
> > > > On Wed, 2009-03-04 at 10:55 -0600, Shawn McKenzie wrote:
> > > >> Robert Cummings wrote:
> > > >>> On Tue, 2009-03-03 at 21:18 -0600, Shawn McKenzie wrote:
> > >  Matthew Croud wrote:
> > > > Hello,
> > > >
> > > > First post here, I'm in the process of learning PHP , I'm digesting
> > a
> > > > few books as we speak.
> > > > I'm working on a content heavy website that provides a lot of
> > > > information, a template system would be great and so i've been
> > looking
> > > > at ways to create dynamic data with a static navigation system.
> > > >
> > > > So far, using the require_once(); function seems to fit the bill in
> > > > order to bring in the same header html file on each page.
> > > > I've also looked at Smartys template system.
> > > >
> > > > I wondered how you folk would go about creating a template system ?
> > > >
> > > > My second question might be me jumping the gun here, I haven't come
> > > > across this part in my book but i'll ask about it anyway.  I often
> > see
> > > > websites that have a dynamic body and static header, and their web
> > > > addresses end like this: "index.php?id=445" where 445 i presume is
> > some my
> > > > file reference.
> > > > What is this called ?  It seems like the system i'm after but it
> > doesn't
> > > > appear in my book,  If anyone could let me know what this page id
> > > > subject is called i can do some research on the subject.
> > > >
> > > > Thanks for any help you can provide :)
> > > >
> > > > Matt.
> > > >
> > >  I have written a popular theme/template system for some CMS systems.
> >  In
> > >  my opinion, templating is only needed for those that are totally
> > >  ignorant of the concept of programming languages in general.
> > > >>> I'm not sure... but I'm pretty sur eyou just called me ignorant.
> > Blanket
> > > >>> statements like that one above are themselves ignorant.
> > > >>>
> > > >>> Cheers,
> > > >>> Rob.
> > > >> Well then you're ignorant because I didn't call you ignorant!  Didn't
> > > >> you write your own template system?
> > > >>
> > > >> Seriously though, I should have worded that differently.  I guess the
> > > >> second paragraph was more what I was after.  But to clarify the first
> > > >> paragraph, I would suspect if they are anything like me, many of those
> > > >> that know and use PHP prefer to do control type things in PHP (loops,
> > > >> ifs, includes, etc.).  I know I do.  I like templating in that I use a
> > > >> template (HTML file) and add echos, or use simple templating logic so
> > > >> that {somevar} echoes $somevar, but why replicate what PHP can do with
> > a
> > > >> separate language?
> > > >
> > > > To punt what is repeated over and over during runtime to a single
> > > > compilation phase when building the template target. To simplify the
> > use
> > > > of parameters so that they can be used in arbitrary order with default
> > > > values. To allow for the encapsulation of complex content in tag format
> > > > that benefits from building at compile time and from being encapsulated
> > > > in custom tags that integrate well with the rest of the HTML body. To
> > > > remove the necessaity of constantly moving in and out of PHP tags. To
> > > > speed up a site. To speed up development. To make easier to use for
> > > > non-developers. To integrate standards compliance checks into the build
> > > > phase. To do sooo many things that are just inconvenient
> > and
> > > > tedious using intermingled PHP code with fixed parameters order (or
> > > > alternatively a big fugly array).
> > > >
> > > > Cheers,
> > > > Rob.
> > >
> > > Is that it?
> >
> > No... I could have gone on :)
> 
> 
> a bit ot, but id like to ask about TemplateJinn, Rob.  do you have to run
> the compile pass, or can it fall back to runtime content inclusion?  and no,
> ive not yet finished, RTFM :)

You can manually run the compile pass (one or more pages or entire
site). Or if enabled via configuration it can automatically detect page
dependency changes and recompile as necessary (great for development
since reloading in browser causes auto recompile). On live servers I
disable the auto compile option usually. The templates allow embedding
PHP code if you so wish, so you could embed run-time includes if you
wanted. Or you could create a tag that performs a run-time include...
I've used both methods for different projects. Legacy code or non-native
systems sometimes warrant chunking... so can compile content chunks that
benefit from custom tags but can themselves be included at runtime via
traditional include philosophies (header.php, footer.php, etc). I've
done this for generating custom Media

Re: [PHP] Re: Question about template systems

2009-03-04 Thread Nathan Nobbe
On Wed, Mar 4, 2009 at 11:51 AM, Robert Cummings wrote:

> On Wed, 2009-03-04 at 12:46 -0600, Shawn McKenzie wrote:
> > Robert Cummings wrote:
> > > On Wed, 2009-03-04 at 10:55 -0600, Shawn McKenzie wrote:
> > >> Robert Cummings wrote:
> > >>> On Tue, 2009-03-03 at 21:18 -0600, Shawn McKenzie wrote:
> >  Matthew Croud wrote:
> > > Hello,
> > >
> > > First post here, I'm in the process of learning PHP , I'm digesting
> a
> > > few books as we speak.
> > > I'm working on a content heavy website that provides a lot of
> > > information, a template system would be great and so i've been
> looking
> > > at ways to create dynamic data with a static navigation system.
> > >
> > > So far, using the require_once(); function seems to fit the bill in
> > > order to bring in the same header html file on each page.
> > > I've also looked at Smartys template system.
> > >
> > > I wondered how you folk would go about creating a template system ?
> > >
> > > My second question might be me jumping the gun here, I haven't come
> > > across this part in my book but i'll ask about it anyway.  I often
> see
> > > websites that have a dynamic body and static header, and their web
> > > addresses end like this: "index.php?id=445" where 445 i presume is
> some my
> > > file reference.
> > > What is this called ?  It seems like the system i'm after but it
> doesn't
> > > appear in my book,  If anyone could let me know what this page id
> > > subject is called i can do some research on the subject.
> > >
> > > Thanks for any help you can provide :)
> > >
> > > Matt.
> > >
> >  I have written a popular theme/template system for some CMS systems.
>  In
> >  my opinion, templating is only needed for those that are totally
> >  ignorant of the concept of programming languages in general.
> > >>> I'm not sure... but I'm pretty sur eyou just called me ignorant.
> Blanket
> > >>> statements like that one above are themselves ignorant.
> > >>>
> > >>> Cheers,
> > >>> Rob.
> > >> Well then you're ignorant because I didn't call you ignorant!  Didn't
> > >> you write your own template system?
> > >>
> > >> Seriously though, I should have worded that differently.  I guess the
> > >> second paragraph was more what I was after.  But to clarify the first
> > >> paragraph, I would suspect if they are anything like me, many of those
> > >> that know and use PHP prefer to do control type things in PHP (loops,
> > >> ifs, includes, etc.).  I know I do.  I like templating in that I use a
> > >> template (HTML file) and add echos, or use simple templating logic so
> > >> that {somevar} echoes $somevar, but why replicate what PHP can do with
> a
> > >> separate language?
> > >
> > > To punt what is repeated over and over during runtime to a single
> > > compilation phase when building the template target. To simplify the
> use
> > > of parameters so that they can be used in arbitrary order with default
> > > values. To allow for the encapsulation of complex content in tag format
> > > that benefits from building at compile time and from being encapsulated
> > > in custom tags that integrate well with the rest of the HTML body. To
> > > remove the necessaity of constantly moving in and out of PHP tags. To
> > > speed up a site. To speed up development. To make easier to use for
> > > non-developers. To integrate standards compliance checks into the build
> > > phase. To do sooo many things that are just inconvenient
> and
> > > tedious using intermingled PHP code with fixed parameters order (or
> > > alternatively a big fugly array).
> > >
> > > Cheers,
> > > Rob.
> >
> > Is that it?
>
> No... I could have gone on :)


a bit ot, but id like to ask about TemplateJinn, Rob.  do you have to run
the compile pass, or can it fall back to runtime content inclusion?  and no,
ive not yet finished, RTFM :)

also, morbidly curious, have you looked at blitz; thoughts ?

thx,

-nathan


Re: [PHP] Re: Question about template systems

2009-03-04 Thread Robert Cummings
On Wed, 2009-03-04 at 12:46 -0600, Shawn McKenzie wrote:
> Robert Cummings wrote:
> > On Wed, 2009-03-04 at 10:55 -0600, Shawn McKenzie wrote:
> >> Robert Cummings wrote:
> >>> On Tue, 2009-03-03 at 21:18 -0600, Shawn McKenzie wrote:
>  Matthew Croud wrote:
> > Hello,
> >
> > First post here, I'm in the process of learning PHP , I'm digesting a
> > few books as we speak.
> > I'm working on a content heavy website that provides a lot of
> > information, a template system would be great and so i've been looking
> > at ways to create dynamic data with a static navigation system.
> >
> > So far, using the require_once(); function seems to fit the bill in
> > order to bring in the same header html file on each page.
> > I've also looked at Smartys template system.
> >
> > I wondered how you folk would go about creating a template system ?
> >
> > My second question might be me jumping the gun here, I haven't come
> > across this part in my book but i'll ask about it anyway.  I often see
> > websites that have a dynamic body and static header, and their web
> > addresses end like this: "index.php?id=445" where 445 i presume is some 
> > my 
> > file reference.
> > What is this called ?  It seems like the system i'm after but it doesn't
> > appear in my book,  If anyone could let me know what this page id
> > subject is called i can do some research on the subject.
> >
> > Thanks for any help you can provide :)
> >
> > Matt.
> >  
>  I have written a popular theme/template system for some CMS systems.  In
>  my opinion, templating is only needed for those that are totally
>  ignorant of the concept of programming languages in general.
> >>> I'm not sure... but I'm pretty sur eyou just called me ignorant. Blanket
> >>> statements like that one above are themselves ignorant.
> >>>
> >>> Cheers,
> >>> Rob.
> >> Well then you're ignorant because I didn't call you ignorant!  Didn't
> >> you write your own template system?
> >>
> >> Seriously though, I should have worded that differently.  I guess the
> >> second paragraph was more what I was after.  But to clarify the first
> >> paragraph, I would suspect if they are anything like me, many of those
> >> that know and use PHP prefer to do control type things in PHP (loops,
> >> ifs, includes, etc.).  I know I do.  I like templating in that I use a
> >> template (HTML file) and add echos, or use simple templating logic so
> >> that {somevar} echoes $somevar, but why replicate what PHP can do with a
> >> separate language?
> > 
> > To punt what is repeated over and over during runtime to a single
> > compilation phase when building the template target. To simplify the use
> > of parameters so that they can be used in arbitrary order with default
> > values. To allow for the encapsulation of complex content in tag format
> > that benefits from building at compile time and from being encapsulated
> > in custom tags that integrate well with the rest of the HTML body. To
> > remove the necessaity of constantly moving in and out of PHP tags. To
> > speed up a site. To speed up development. To make easier to use for
> > non-developers. To integrate standards compliance checks into the build
> > phase. To do sooo many things that are just inconvenient and
> > tedious using intermingled PHP code with fixed parameters order (or
> > alternatively a big fugly array).
> > 
> > Cheers,
> > Rob.
> 
> Is that it?

No... I could have gone on :)

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] Re: Question about template systems

2009-03-04 Thread Shawn McKenzie
Robert Cummings wrote:
> On Wed, 2009-03-04 at 10:55 -0600, Shawn McKenzie wrote:
>> Robert Cummings wrote:
>>> On Tue, 2009-03-03 at 21:18 -0600, Shawn McKenzie wrote:
 Matthew Croud wrote:
> Hello,
>
> First post here, I'm in the process of learning PHP , I'm digesting a
> few books as we speak.
> I'm working on a content heavy website that provides a lot of
> information, a template system would be great and so i've been looking
> at ways to create dynamic data with a static navigation system.
>
> So far, using the require_once(); function seems to fit the bill in
> order to bring in the same header html file on each page.
> I've also looked at Smartys template system.
>
> I wondered how you folk would go about creating a template system ?
>
> My second question might be me jumping the gun here, I haven't come
> across this part in my book but i'll ask about it anyway.  I often see
> websites that have a dynamic body and static header, and their web
> addresses end like this: "index.php?id=445" where 445 i presume is some 
> my 
> file reference.
> What is this called ?  It seems like the system i'm after but it doesn't
> appear in my book,  If anyone could let me know what this page id
> subject is called i can do some research on the subject.
>
> Thanks for any help you can provide :)
>
> Matt.
>  
 I have written a popular theme/template system for some CMS systems.  In
 my opinion, templating is only needed for those that are totally
 ignorant of the concept of programming languages in general.
>>> I'm not sure... but I'm pretty sur eyou just called me ignorant. Blanket
>>> statements like that one above are themselves ignorant.
>>>
>>> Cheers,
>>> Rob.
>> Well then you're ignorant because I didn't call you ignorant!  Didn't
>> you write your own template system?
>>
>> Seriously though, I should have worded that differently.  I guess the
>> second paragraph was more what I was after.  But to clarify the first
>> paragraph, I would suspect if they are anything like me, many of those
>> that know and use PHP prefer to do control type things in PHP (loops,
>> ifs, includes, etc.).  I know I do.  I like templating in that I use a
>> template (HTML file) and add echos, or use simple templating logic so
>> that {somevar} echoes $somevar, but why replicate what PHP can do with a
>> separate language?
> 
> To punt what is repeated over and over during runtime to a single
> compilation phase when building the template target. To simplify the use
> of parameters so that they can be used in arbitrary order with default
> values. To allow for the encapsulation of complex content in tag format
> that benefits from building at compile time and from being encapsulated
> in custom tags that integrate well with the rest of the HTML body. To
> remove the necessaity of constantly moving in and out of PHP tags. To
> speed up a site. To speed up development. To make easier to use for
> non-developers. To integrate standards compliance checks into the build
> phase. To do sooo many things that are just inconvenient and
> tedious using intermingled PHP code with fixed parameters order (or
> alternatively a big fugly array).
> 
> Cheers,
> Rob.

Is that 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] Re: Question about template systems

2009-03-04 Thread Robert Cummings
On Wed, 2009-03-04 at 10:55 -0600, Shawn McKenzie wrote:
> Robert Cummings wrote:
> > On Tue, 2009-03-03 at 21:18 -0600, Shawn McKenzie wrote:
> >> Matthew Croud wrote:
> >>> Hello,
> >>>
> >>> First post here, I'm in the process of learning PHP , I'm digesting a
> >>> few books as we speak.
> >>> I'm working on a content heavy website that provides a lot of
> >>> information, a template system would be great and so i've been looking
> >>> at ways to create dynamic data with a static navigation system.
> >>>
> >>> So far, using the require_once(); function seems to fit the bill in
> >>> order to bring in the same header html file on each page.
> >>> I've also looked at Smartys template system.
> >>>
> >>> I wondered how you folk would go about creating a template system ?
> >>>
> >>> My second question might be me jumping the gun here, I haven't come
> >>> across this part in my book but i'll ask about it anyway.  I often see
> >>> websites that have a dynamic body and static header, and their web
> >>> addresses end like this: "index.php?id=445" where 445 i presume is some 
> >>> my 
> >>> file reference.
> >>> What is this called ?  It seems like the system i'm after but it doesn't
> >>> appear in my book,  If anyone could let me know what this page id
> >>> subject is called i can do some research on the subject.
> >>>
> >>> Thanks for any help you can provide :)
> >>>
> >>> Matt.
> >>>  
> >> I have written a popular theme/template system for some CMS systems.  In
> >> my opinion, templating is only needed for those that are totally
> >> ignorant of the concept of programming languages in general.
> > 
> > I'm not sure... but I'm pretty sur eyou just called me ignorant. Blanket
> > statements like that one above are themselves ignorant.
> > 
> > Cheers,
> > Rob.
> 
> Well then you're ignorant because I didn't call you ignorant!  Didn't
> you write your own template system?
> 
> Seriously though, I should have worded that differently.  I guess the
> second paragraph was more what I was after.  But to clarify the first
> paragraph, I would suspect if they are anything like me, many of those
> that know and use PHP prefer to do control type things in PHP (loops,
> ifs, includes, etc.).  I know I do.  I like templating in that I use a
> template (HTML file) and add echos, or use simple templating logic so
> that {somevar} echoes $somevar, but why replicate what PHP can do with a
> separate language?

To punt what is repeated over and over during runtime to a single
compilation phase when building the template target. To simplify the use
of parameters so that they can be used in arbitrary order with default
values. To allow for the encapsulation of complex content in tag format
that benefits from building at compile time and from being encapsulated
in custom tags that integrate well with the rest of the HTML body. To
remove the necessaity of constantly moving in and out of PHP tags. To
speed up a site. To speed up development. To make easier to use for
non-developers. To integrate standards compliance checks into the build
phase. To do sooo many things that are just inconvenient and
tedious using intermingled PHP code with fixed parameters order (or
alternatively a big fugly array).

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] Re: Question about template systems

2009-03-04 Thread Shawn McKenzie
Robert Cummings wrote:
> On Tue, 2009-03-03 at 21:18 -0600, Shawn McKenzie wrote:
>> Matthew Croud wrote:
>>> Hello,
>>>
>>> First post here, I'm in the process of learning PHP , I'm digesting a
>>> few books as we speak.
>>> I'm working on a content heavy website that provides a lot of
>>> information, a template system would be great and so i've been looking
>>> at ways to create dynamic data with a static navigation system.
>>>
>>> So far, using the require_once(); function seems to fit the bill in
>>> order to bring in the same header html file on each page.
>>> I've also looked at Smartys template system.
>>>
>>> I wondered how you folk would go about creating a template system ?
>>>
>>> My second question might be me jumping the gun here, I haven't come
>>> across this part in my book but i'll ask about it anyway.  I often see
>>> websites that have a dynamic body and static header, and their web
>>> addresses end like this: "index.php?id=445" where 445 i presume is some my 
>>> file reference.
>>> What is this called ?  It seems like the system i'm after but it doesn't
>>> appear in my book,  If anyone could let me know what this page id
>>> subject is called i can do some research on the subject.
>>>
>>> Thanks for any help you can provide :)
>>>
>>> Matt.
>>>  
>> I have written a popular theme/template system for some CMS systems.  In
>> my opinion, templating is only needed for those that are totally
>> ignorant of the concept of programming languages in general.
> 
> I'm not sure... but I'm pretty sur eyou just called me ignorant. Blanket
> statements like that one above are themselves ignorant.
> 
> Cheers,
> Rob.

Well then you're ignorant because I didn't call you ignorant!  Didn't
you write your own template system?

Seriously though, I should have worded that differently.  I guess the
second paragraph was more what I was after.  But to clarify the first
paragraph, I would suspect if they are anything like me, many of those
that know and use PHP prefer to do control type things in PHP (loops,
ifs, includes, etc.).  I know I do.  I like templating in that I use a
template (HTML file) and add echos, or use simple templating logic so
that {somevar} echoes $somevar, but why replicate what PHP can do with a
separate language?

-- 
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] Re: Question about template systems

2009-03-04 Thread Robert Cummings
On Tue, 2009-03-03 at 21:18 -0600, Shawn McKenzie wrote:
> Matthew Croud wrote:
> > Hello,
> > 
> > First post here, I'm in the process of learning PHP , I'm digesting a
> > few books as we speak.
> > I'm working on a content heavy website that provides a lot of
> > information, a template system would be great and so i've been looking
> > at ways to create dynamic data with a static navigation system.
> > 
> > So far, using the require_once(); function seems to fit the bill in
> > order to bring in the same header html file on each page.
> > I've also looked at Smartys template system.
> > 
> > I wondered how you folk would go about creating a template system ?
> > 
> > My second question might be me jumping the gun here, I haven't come
> > across this part in my book but i'll ask about it anyway.  I often see
> > websites that have a dynamic body and static header, and their web
> > addresses end like this: "index.php?id=445" where 445 i presume is some my 
> > file reference.
> > What is this called ?  It seems like the system i'm after but it doesn't
> > appear in my book,  If anyone could let me know what this page id
> > subject is called i can do some research on the subject.
> > 
> > Thanks for any help you can provide :)
> > 
> > Matt.
> >  
> 
> I have written a popular theme/template system for some CMS systems.  In
> my opinion, templating is only needed for those that are totally
> ignorant of the concept of programming languages in general.

I'm not sure... but I'm pretty sur eyou just called me ignorant. Blanket
statements like that one above are themselves ignorant.

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] Re: Question about template systems

2009-03-03 Thread Chetan Rane
Hi

I think what you are looking for is static Header Footer and dynamic
content.
One way of doing this is by having the front controller pattern

For example : consider the following list of files in your application

1000.php
2000.php
1001.php
3000.php

In the front controller Pattern we usually have a only one file referenced
all eth time and most of the times it is Index.php

The code of your index.php file would be something like this

require_once "header.php";

require_once $_GET['r'].".php";

require_once "footer.php";

once this is done. To access any of the above mentioned files your URL will
be like this

index.php?r=1000 or index.php?r=2000 or index.php?r=1001 etc

The code given above is just the start point and is not secure enough and
had a Code injection threat. 
However I think this is enough to get you started.
You can do more research on what is Code Injection and how to avoid it.



From: Shawn McKenzie [mailto:nos...@mckenzies.net] 
Sent: Wednesday, March 04, 2009 9:05 AM
To: php-general@lists.php.net
Subject: [PHP] Re: Question about template systems

Shawn McKenzie wrote:
> Matthew Croud wrote:
>> Hello,
>>
>> First post here, I'm in the process of learning PHP , I'm digesting a
>> few books as we speak.
>> I'm working on a content heavy website that provides a lot of
>> information, a template system would be great and so i've been looking
>> at ways to create dynamic data with a static navigation system.
>>
>> So far, using the require_once(); function seems to fit the bill in
>> order to bring in the same header html file on each page.
>> I've also looked at Smartys template system.
>>
>> I wondered how you folk would go about creating a template system ?
>>
>> My second question might be me jumping the gun here, I haven't come
>> across this part in my book but i'll ask about it anyway.  I often see
>> websites that have a dynamic body and static header, and their web
>> addresses end like this: "index.php?id=445" where 445 i presume is some
my 
>> file reference.
>> What is this called ?  It seems like the system i'm after but it doesn't
>> appear in my book,  If anyone could let me know what this page id
>> subject is called i can do some research on the subject.
>>
>> Thanks for any help you can provide :)
>>
>> Matt.
>>  
> 
> I have written a popular theme/template system for some CMS systems.  In
> my opinion, templating is only needed for those that are totally
> ignorant of the concept of programming languages in general.  It helps
> for those designers that know HTML or they export their graphics as HTML
> and know enough to modify it or add some simple tags like {post-date} to
> HTML.  That's it!  No loops, no ifs, nothing.  Simple things
> designers/users can add that represent some complex code, queries, etc...
> 
> PHP IS a template language.  You can easily separate your logic and
> design/display using PHP.  Anything more than abstracting some complex
> code to some simple var is overkill.  If you want to display a dropdown
> of categories, and the code needed is a database query and some PHP
> logic, etc., then it makes sense in my above scenario to do this in code
> and then assign the result to a template var like {categories-dropdown}
> that the designer/user can use in the HTML.  Other than that its just
waste.
> 
> Smarty and similar template approaches just take PHP (but more limited)
> and make it look slightly different.  Anyone who doesn't know or want to
> know anything about programming will not see the difference between PHP
> and Smarty.  Consider the following:
> 
> PHP: 
> 
> Smarty: {somevar}
> //oh except in your PHP you have to do the following
> //$smarty->assign('somevar', $somevar);
> //$smarty->display('some.tpl');
> 
> PHP: include('header.tpl');
> 
> Smarty: {include file="header.tpl"}
> 
> Don't even get me started on loops and conditionals.  Smarty just
> replicates PHP, except it looks slightly different and is much less
> powerful.  If you are confused with:
> 
> if ($something) {
>   echo "Some stuff...";
> } else {
>   echo "Some other stuff...";
> }
> 
> Why is this better:
> 
> {if $something}
> Some stuff...
> {else}
> Some other stuff...
> {/if}
> 
> Like I said earlier, if you have some complex code that you can reduce
> to a simple tag or something that a designer can insert into HTML then
> great.  If not then it is just unsuccessfully trying to replicate PHP!

Actually, I forgot myself and the alternative syntax:

if($something):
echo "Some stuff...";
else:
echo "Some other stuff...";
endif;

Hardly different...

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

-- 
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] Re: Question about template systems

2009-03-03 Thread Ashley Sheridan
On Tue, 2009-03-03 at 20:53 +0100, Martin ZvarĂ­k wrote:
> Matthew Croud napsal(a):
> > Hello,
> > 
> > First post here, I'm in the process of learning PHP , I'm digesting a 
> > few books as we speak.
> > I'm working on a content heavy website that provides a lot of 
> > information, a template system would be great and so i've been looking 
> > at ways to create dynamic data with a static navigation system.
> > 
> > So far, using the require_once(); function seems to fit the bill in 
> > order to bring in the same header html file on each page.
> > I've also looked at Smartys template system.
> 
> 
> If you are looking for performance stick to Blitz PHP - the only true 
> template system.
> 
> Martin
> 
> > Thanks for any help you can provide :)
> > 
> > Matt.
> >  
> 
For now, while you're learning about PHP, I'd use an existing template
system and tweak it to your needs. As you learn more, and need something
a little more bespoke, then you can look at making one yourself based on
what you've learnt about the coding and about existing template systems.
I've never used any myself, so I can't comment from first-hand
experience, but perhaps the Wikipedia entry may be of some help:
http://en.wikipedia.org/wiki/Template_engine_(web) 


Ash
www.ashleysheridan.co.uk


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