PHP templates for repeated content
Moderator: General Moderators
PHP templates for repeated content
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?
- Jonah Bron
- DevNet Master
- Posts: 2764
- Joined: Thu Mar 15, 2007 6:28 pm
- Location: Redding, California
- AbraCadaver
- DevNet Master
- Posts: 2572
- Joined: Mon Feb 24, 2003 10:12 am
- Location: The Republic of Texas
- Contact:
Re: PHP templates for repeated content
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.
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
Re: PHP templates for repeated content
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".
<?=$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".