- This topic is empty.
-
AuthorPosts
-
September 12, 2013 at 11:05 am #149849CarraraWebsiteSolutionsParticipant
Hi I am trying to get it so any file that is ending in .tpl will have header and footer added. So far can only get one home page
<?php $path = $_SERVER['DOCUMENT_ROOT']; $path .= "/template/common/header.tpl"; $path .= ".tpl"; include_once($path); ?>
September 12, 2013 at 7:04 pm #149902__ParticipantHi I am trying to get it so any file that is ending in .tpl will have header and footer added. So far can only get one home page
I don’t follow. In your example above,
$path
would contain “{path-to-your-document-root}/template/common/header.tpl.tpl
“. That doesn’t sound like what you’re describing.If you want your templates to have a shared header + footer, just add them to the template:
<?php include( 'header.tpl' ); <p>This is my page template</p> include('footer.tpl');
September 13, 2013 at 1:57 am #149922CarraraWebsiteSolutionsParticipantI have been google today found out to be able to do what I am after I need A MVC template engine would you know a easy one I had look in to smarty php but need something easy to learn off.
September 13, 2013 at 12:45 pm #150007__ParticipantI have been google today found out to be able to do what I am after I need A MVC template engine
Instead of just jumping to conclusions, you should research what “MVC” means – your templates are only the “V” (“View”) part.
While I do recommend learning about and following MVC patterns, you do not need to change your entire approach simply to include a shared header and footer on your pages.
Also, while I don’t really like Smarty, it is suited for use in an MVC structure.
September 13, 2013 at 2:50 pm #150017AlenParticipantOverview of MVC Design: http://youtu.be/qXRcVhWxuaU
Some PHP frameworks that implement MVC.
- Laravel
- CodeIgniter
- CakePHP
- Symfony
- Zend Framework
- Yii
- FuelPHP
- Kohana
I like Laravel. And if you’re interested in learning more about the framework, Jeffrey Way is working on a site that will take you from novice to pro for very low monthly price. http://laracasts.com & http://laracasts.com/forum/
Although, like @traq said you should really figure out what you’re after then seek the “right” solution. You might not need framework. Or the MVC design pattern.
-
AuthorPosts
- The forum ‘Back End’ is closed to new topics and replies.