Page 1 of 1
PHP templates for repeated content
Posted: Tue Jan 19, 2010 11:21 am
by Ironwil
I'm completely new to PHP, having done nearly all of my developing in ASP.NET C# previously. I've done quite a bit of work with Flash and a little Flex, but not nearly as much as ASP.NET. In ASP.NET, there are MasterPages that provide a means to code repeated content only once, so you're not repeating your header, footer and navigation elements for each page. I'm wondering what the equivalent in PHP would be. Is there some kind of template to use, or are partial pages included by some PHP statements?
Posted: Tue Jan 19, 2010 12:23 pm
by Jonah Bron
If I understand, there are lots. Joomla, Wordpress, Drupal, just to name a few. But you don't really need these for simply repeating a header and footer. All you have to do is create seperate files with your header HTML and footer HTML, and include() them.
Re: PHP templates for repeated content
Posted: Tue Jan 19, 2010 12:51 pm
by AbraCadaver
Along with what Jonah said, there are template systems such as Smarty that provide similar functionality to the Master/Content pages of ASP .NET. I prefer to build my own though. You might be interested in a framework, which is really what ASP .NET is right? I prefer CakePHP, and there is one modeled somewhat after .NET called Prado.
Re: PHP templates for repeated content
Posted: Wed Jan 20, 2010 9:16 am
by josh
I use Zend_View (part of zend framework)
<?=$this->partial( 'foo.phtml', array( 'baz' => 'bat' ) )?>
Then in foo.phtml $this->baz points to 'bat'.
In Magento it is abstracted 1 layer further. Instead of referencing foo.phtml directly, you give it a name like 'foo'. Then different themes can make 'foo' point to different files. Basically giving a designer the ability to "override".