views:

70

answers:

4

A PHP content management system usually has its own template engine be it smarty or some other custom template engine specific for that CMS. How might I possibly get a CMS theme to work on a normal PHP website without converting the website to a website powered by that CMS?

Can I "teach" the website to use the template engine of a content management system (only the template engine and not the actual cms engine and its features)? My question may not be very clear, but I'm sure someone here knows enough about template engines to tell me the right approach to do this.

+2  A: 

If it is the case that you have some pages already that has been implemented using some template system and you want to be able use them without or little changes you should look at Twig or a Twig enabled CMS. (an offspring of the Symphony project)

Twig enables you to write your own Lexer and Parser, thou it already has it's own template syntax.

This means that you could use Smarty or Mustache syntax for your templates, or any other syntax you would prefer.

Michael
You could use Symphony with Twig if you find Symphony templates to complicated or you have a need to store the templates. IMO Twig is more suitable for that.
Michael
+3  A: 

It depends on the CMS and templating system it uses. Smarty can be easily implemented on a static site so it would be as simple as removing the CMS bits and replacing them with content. In the case of Joomla you could take the template files and remove the module code and replace it with content.

Brent Friar
+3  A: 

I've been thinking about your question for the past 15 minutes and I don't think this can be done without copying the exact theme engine the CMS uses. But the theme engine of a CMS still ties into the API of the CMS, which effectively means you need your website to also understand the API of the CMS. Basically you are turning your website into that CMS.

P.S. I'm not an expert on this so maybe I got it all wrong.

jblue
I think your have a good point - you would have to adapt to the API of the CMS, depending on the level of functionality. Less is easy. Also depending on how the modules (if such exists) are designed.
Michael
+1  A: 

You can save the template out as flat HTML and then place in some basic tags to output your own content e.g

<div id="mainmenu"><?php echo $mainMenu ?></div>

etc

This way you can use the theme with your own PHP code.

niggles