|Simple web page layout and templating in PHP||#1|
In the past I've written sites in ASP.NET just to get nice reusable templating via master pages (layouts) and user controls (partials). I'm talking about sites that have no more complicated code in them than simple variable substitution in templates - I'm just using it to keep my HTML organized. It's great to be able to define the basic layout of your page in one file, and then just fill in the holes for each individual page, re-using some common bits as user controls.
However, I'd rather not continue using Windows hosting, so I'd like to write static pages in PHP, which runs everywhere. In the past I've written myself a poor-man's user control for PHP that just unpacks an array and includes a template, but that's clunky and still requires me to put PHP includes all over my pages. I feel like Smarty or one of the other big templating languages for PHP is overkill for just organizing some "static" pages.
I've considered just doing the pages in Ruby on Rails because I really like HAML/SASS and the layout/partial model, but having a whole rails app for static content seems silly. But I haven't found anything that seems just right in PHP. Can any PHP gurus recommend anything? I want something more sophisticated than "include" but I don't really need much. That said, something that could give me layouts/partials AND HAML/SASS would be heaven. I've looked at phammable but it doesn't look like it solves the layout/partial problem.
Again, I'm not looking for something as complex as Smarty, and I don't want a full CMS. I just want something that will let me properly modularize the HTML of my site. We're talking one step beyond static HTML here.
posted date: 2008-12-22 01:18:00
|Re: Simple web page layout and templating in PHP||#3|
I would suggest to you to look at Drupal and its Block templating model. I think its just what you need.
posted date: 2008-12-22 01:59:00
|Re: Simple web page layout and templating in PHP||#4|
Maybe you should take a look at some content management systems. Drupal is famous in PHP.
posted date: 2008-12-22 02:01:00
|Re: Simple web page layout and templating in PHP||#5|
Drupal really is a simple and extensible CMS. There is a learning curve, but it's strengths are that is starts small out of the box and can grow with your needs and the community is pretty tight about the quality of the code that's written (though I personally find that some of the modules get a little two function happy).They have a simple stripped down version of the Zen theme, that lets you create the HTML you want to use. Time spent learning this CMS is time well spent, especially if PHP is already your native language.
posted date: 2008-12-22 03:57:00
|Re: Simple web page layout and templating in PHP||#6|
but I think Drupal is also very much overkill for just mostly static webpages like he requests...
posted date: 2008-12-22 12:38:00
|Re: Simple web page layout and templating in PHP||#7|
I don't think that there is a very clean interim from include to CMS. Like I said, I understand that Drupal has a learning curve, but once understood, and with the modularization, it's extremely strong for using as a base for all all website production.
posted date: 2008-12-22 12:44:00
|Re: Simple web page layout and templating in PHP||#8|
From what i understand, you don't want a full fledged cms and no overkill templating engine like Smarty. Php is a templating system and if you want to properly modularize it, that's up to you.But i understand, those php tags between your html doesn't look pretty. (Although using shorttags minimizes this...)You can always use PEAR Templating system, it's available by default on most php installations. I would also recommend the CodeIgniter MCV framework because it's really lightweight. You choose which libraries get autoloaded.
posted date: 2008-12-22 12:47:00
|Re: Simple web page layout and templating in PHP||#9|
I totally agree that Drupal is worth the effort, but in this case i don't think that's what he's looking for. But hey, it's up to him to decide... :-)
posted date: 2008-12-22 12:49:00
|Re: Simple web page layout and templating in PHP||#10|
Zend_View supports layouts, partials and placeholders. Also checkout a new templating language called Dwoo which is similar to Smarty but also takes some ideas from Django templating. And finally, Calypso which is a Django template language clone for PHP
posted date: 2008-12-30 20:49:00
|Re: Simple web page layout and templating in PHP||#11|
Can you use Zend_View without having to use everything else? I love working with the Zend Framework, but it's overkill when you only really care about using Zend_View.
posted date: 2009-06-19 00:05:00
|Re: Simple web page layout and templating in PHP||#12|
About six months ago, I started using the Zend Framework. I got used to working with layouts and partials, and never wanted to go back creating sites without it. But for small sites, ZF is just too bulky. It's overkill to use ZF for a site that could be done in HTML.Check out EuropaPHP. It's a super lightweight, PHP based layout framework. It's brand new as a framework, but so far, I like it a lot! It allows me to use layouts and doesn't require a huge library and strict rules to achieve the same results.
posted date: 2009-06-19 03:15:00
|select page: « 1 2 »|