Re: Separation of logic, design and data



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.


.



Relevant Pages

  • Re: How do we get there from here?
    ... > then sub the whole of that generated markup into the template? ... layed out on the fly, a simple IMG tag, or even an entire HTML document. ... PHP scripting provides 10 times the features of both of these ... idea as tokens can eliminate a huge amount of maintance, ...
    (comp.databases.pick)
  • Re: nested conditional that can identify parent page?
    ... and specify the files in the array including ... try to make as little php and html mix as possible, have a template ...
    (alt.php)
  • Re: A better XSS trap (Feedback wanted)
    ... better to always be forced to choose the right filter depending on the ... It makes template code shorter, ... and easier to understand for non-programmers (doing the HTML design). ... I personally stick to PHP only, because the I gain of a template engine ...
    (comp.lang.php)
  • Re: best way for PHP page
    ... WYSIWYG html editor and work with other colleagues who have no php ... I can then call the template from a function feeding the title and any ... interactivity and client/server interactivity. ...
    (php.general)
  • Re: is anyone here going to help me??? does anyone here know anything at all???
    ... I am very sure that if I post my broken template and they ... Until like three or four days ago, everything on my blog displayed ... The generic Google ad beneath the blog title box displayed perfectly. ... I tried to publish and got a broken HTML error. ...
    (rec.gambling.poker)