This is a proposal for adding actual template engine functionality into osCommerce Online Merchant v3.0 to remove PHP code from the content pages.
The proposal is shown through the development of our new website powered by the osCommerce Online Merchant v3.0 framework. The source code to our new website is published as Open Source (BSD license) however it will not be part of osCommerce Online Merchant v3.0 as it is obviously not a general purpose application. As soon as the template engine functionality is finalized, it will be added to the v3.0 framework to not only implement it to the Admin, Setup, and Shop sites, but to also kickstart the initiative of adding a general purpose CMS Site to osCommerce Online Merchant v3.0.
The template engine functionality is currently aimed at developers. An Admin Application will be needed for users to be able to edit page content and see which template engine functionality is available to them.
The source code of our website and the initial template engine functionality is available at:
https://github.com/haraldpdl/oscommerce_website
Instructions for setting up the website is available at the github repository. It is currently only the front page to demonstrate the template engine functionality.
The idea behind the template engine functionality is to NOT add logic into content pages where users and developers need to learn yet another language for conditions or loops - PHP does this just fine.
The idea is to "widgetize" content pages through the use of simple tags used in addition to HTML. Simple processing is taken care of with Tags and more powerful and modular processing is taken care of with Widgets. Both Tags and Widgets are called in the following format, similar to bbcode:
{tag}value{tag}
No closing {/tag} is used - only matching {tag}{tag} pairs are processed.
The following tags are available:
- import - include html content from another file
- lang - get language definition
- link - produce a url
- publiclink - produce a url to a public asset
- value - get the value of a variable
- widget - process widget
It's possible to nest Tags and by default the same processing is also executed on the output of the Tag, for example using {link}Index{link} is possible in a language definition. This can be disabled at the Tag level if it is not required.
It is up to each Tag to process the string value as it requires. Some Tags may need arguments to be passed - both link and publiclink Tags use | as a separator in the string value to process arguments, example {link}Index|Shop{link} would create a link to the Shop Index page, not to the Index page of the current Site.
For cases where more complex arguments are needed, a variable can be pre-set at the Site level to make it available to all of its Applications, or at the Application level specific for that Application. This is contained in $OSCOM_Template->_values[] and the value can be retrieved with the {value} Tag.
Widgets are used where coding logic is needed or to add independent blocks to a page. Each Widget has it's own language definition file and can be added to any page.
Please take a look at the source and provide feedback on the direction this is going in. Caching will need to be looked into.
Thanks!
Edited by Harald Ponce de Leon, 03 February 2012 - 11:02 AM.











