Re: Separation of logic, design and data
- From: Erwin Moller <since_humans_read_this_I_am_spammed_too_much@xxxxxxxxxxxxxxxx>
- Date: Thu, 25 Jan 2007 12:04:44 +0100
Toby Inkster wrote:
Erwin Moller wrote:
For example: If you have a navigationbar with many links (for admin eg),
just include a file that contains them.
You can simply include it above every page that uses it.
If you need to add/change anything, you have just one place to check.
Same goes for footers, or other parts of html.
But, in your example, if you have include("nav-links.html") scattered
about on many pages, but you want to move your navigation links from,
say, the top of the page to the bottom, then you need to change each file
that includes it. With mine, you only change one file.
True.
That is the weakness of using includes for HTML pieces.
It can be overcome by using an include in the include, like this:
in header of page:
<?php include 'headerstuff.php'; ?>
and at bottom:
<?php include 'footerstuff.php'; ?>
And then put in the headerstuff.php another include:
[headerstuff.php:]
<?php include 'contactinformation.php'; ?>
If set up like that you can easily move/modify from header to footer by
editting/moving contactinformation.php from headerstuff.php to
footerstuff.php.
But I must admit that approach tends to get a little messy. :-)
And also you must decide beforehand WHERE you want your possible includes.
Personally I prefer the simplicity of includes over the use of a
templatesystem.
I think your template approach is much better if you have to maintain a
website that changes a lot. Then the original extra overhead pays back in
10-fold I expect. :-)
just my 2 cent..
Regards,
Erwin Moller
The method you describe above is how I started using PHP, but as you start
building progressively more complicated sites, it eventually begins to
show its weaknesses. I started there, and now I'm here at my Template
interface solution, and I went through several different techniques on the
way. I'm sure at some point in the future I'll see the weaknesses in my
current technique and move on to something even better, though I'm not
sure what that might be.
Ian mentioned Smarty. I've investigated that too, but found it lacked what
I needed out of a template engine. Smarty looks handy for when there are
large invariable chunks of HTML that need to be used on many pages, and a
handful of variables that just need to be slotted into them. It's not for
me though.
.
- References:
- Separation of logic, design and data
- From: Frank van Wensveen
- Re: Separation of logic, design and data
- From: Erwin Moller
- Re: Separation of logic, design and data
- From: Toby Inkster
- Separation of logic, design and data
- Prev by Date: Re: mysqli connections and oop
- Next by Date: Re: Just PHP will give you nothing unless you upgrade yourself
- Previous by thread: Re: Separation of logic, design and data
- Next by thread: Re: Separation of logic, design and data
- Index(es):
Relevant Pages
|