Nathan Nobbe wrote:
On Mon, May 10, 2010 at 9:19 PM, David McGlone <da...@dmcentral.net> wrote:
On Monday 10 May 2010 22:15:44 Paul M Foster wrote:
On Mon, May 10, 2010 at 06:09:00PM -0400, David McGlone wrote:
On Monday 10 May 2010 13:04:36 richard gray wrote:
On 10/05/2010 18:17, Ashley Sheridan wrote:
It makes sense sometimes to have different files for different
sections of a website. For example, blog.php, gallery.php, cart.php
could deal with the blog, gallery and shopping cart sections for an
artists website. Yes, it could all be achieved with one script
handling everything, but sometimes when the areas of the site
differ
greatly, it results in a lot of extra code to deal with pulling in
the right template and content parts. I've always favoured only
including the code a page needs rather than a huge amount of stuff
that it doesn't.
this isn't necessarily true - the architecture I've developed uses a
single dispatch script (works fine with the mod rewrite option 2
scenario as well) - this script does general checks/security/filters
etc then simply determines what page/function the user wants from the
request ($_GET/$_POST parameter) and passes control to the specific
handler via including the relevant controller module. The controller
module is responsible for which template is required and loads up
specific classes needed to process the request etc so each module
just
loads its own stuff and nothing else so there's no overhead.
This method also has a small extra benefit that the web server
document
root just has a very simple 2 liner script instead a myriad of php
scripts... if the webserver is misconfigured then someone who sees
the
source code doesn't get to see much..
This thread makes me wonder if using Smarty is smart. Does anyone here
use a templeting system such as smarty or am I the only one?
Lots of people use templating systems and particularly Smarty. Here's
the difference between a templating system and just hand-coding:
Hand coding--
<input type="text" name="flavor" size="20" value="<?php echo $flavor;
?>"/>
Templating system:
<input type="text" name="flavor" size="20" value={flavor}/>
(Okay, I'm not familiar with Smarty syntax, but in essence template
systems allow you to type less when you want PHP values to show up on
the page.)
Advantage: It *may* be easier for non-programmers to "read" the page
with templating systems. I'm not sure this is really true. They're still
liable to say, "What the heck is {flavor}?" Besides, my inclination is
to tell designers to make everything look pretty, turn the resulting
HTML over the the coders, who will then mark it up for PHP. After that,
the designers can stay away from it.
Disadvantage: You're adding another layer (and a LOT of code) just to
save yourself some typing. With straight PHP, the server reads the code,
interprets the PHP, substitutes values and shoves the page down to the
browser. With a templating system, the system must load and call the
templating engine, which must then substitute the proper values, and
then output the built page to the browser.
I don't know how everyone else does things, but I get a feeling of being
very
well organized when using smarty.
I have to say that by using smarty, it has also helped me understand PHP
more
in depth. Maybe it's because of the strict organization, or maybe it's
because
I've been practicing a whole lot more. dunno.
if theres one thing i tend to stay away from, or start deleting the second i
inherit a new codebase, its smarty.
ive never seen anything more bloated & ridiculous. hey, lets all learn
*another* set of conventions & syntax on top of what we've already learned,
drop *another* url in our bookmarks and slow down the entire universe in the
process...
imo smarty and most any 'template engine' on top of php can be summarized in
one line of code:
include($someScript); // :P
i did gander at robs template system in interjinn once, but never got my
head wrapped round it; honestly i only gave it a day or so. i prefer to go
the typical route as per above, and omit the bloat that systems like smarty,
savant etc bring to the table.
nothing personal david, just an anti-smarty rant :)
yeah I went down the smarty path a few years ago, through xslt, custom
templates etc.. then one day i realised that Pre Hypertext Processor
basically meant that PHP is a rather fancy template engine, so I use it
instead now :p
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php