2009/3/3 Matthew Croud <m...@obviousdigital.com>

> 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 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.

This could be being handled any number of ways. 445 could refer to a row in
a database, a file on disk or a number of other things. All you really need
to know is that the script will take $_GET['id'], sanitise it (important!)
and use it as a resource identifier in a SQL query, filename or something
else. That will give the script the content to display. It would likely then
include a file containing the common header HTML, output the retrieved
content and then include a file containing the common footer HTML.

Even at the simplest level you'd probably call this an instance of the front
controller pattern (Google it), but they usually go a lot further than this.

As far as templating systems go I personally don't think they add anything
to the equation unless you're working with designers who are already
familiar with something. Separation of logic and content is important,
abstraction away from PHP is not (IMHO).



Reply via email to