What does it take to make a CMS template work on a normal website
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 开发者_StackOverflow社区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.
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.
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.
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.
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.
精彩评论