PHP templates for repeated content

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

Post Reply
Ironwil
Forum Newbie
Posts: 4
Joined: Tue Jan 19, 2010 11:16 am

PHP templates for repeated content

Post 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?
User avatar
Jonah Bron
DevNet Master
Posts: 2764
Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California

Post 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.
User avatar
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

Post 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.
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.
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: PHP templates for repeated content

Post 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".
Post Reply