Welcome Guest, Not a member yet? Register   Sign In
Best templating method?
#2

[eluser]coffeeandcode[/eluser]
I use a template library with a render() method. The render method takes in an array of content views to load, and any needed data. It then loads the content views into a variable, then loads the template view (I have one template view, instead of header, footer, etc) which echos the $content variable in the right place.

Since the content is handled by the content views, the only exceptions to handle would be changes in the template. I would handle that with variables passed to the render function. The template can check if a particular element should be rendered or not:

Code:
<?php if ($sidebar) : ?>
    <div id="sidebar">&lt;?php echo $sidebar ?&gt;</div>
&lt;?php endif; ?&gt;


Messages In This Thread
Best templating method? - by El Forum - 07-27-2010, 07:46 AM
Best templating method? - by El Forum - 07-27-2010, 08:03 AM
Best templating method? - by El Forum - 07-27-2010, 08:11 AM



Theme © iAndrew 2016 - Forum software by © MyBB