Suggestions for a CMS markup language for PHP
- by Yanick Rochon
As a learning experience, and as project, I am attempting to write a CMS module for ZF2. One of the functionality I would like to have is the possibility of adding dynamic contents in the pages by calling PHP functions in the view scripts.
However, I do not want to give the users freedom in writing PHP code directly inside the page content, but rather implement custom view helpers (or widgets) to handle logic. For example: calling partial, partialLoop, url, etc. specifying arguments and all.
I liked the idea of extending Markdown but this would get complicated when trying to add custom CSS class to elements, etc.
Then I had the idea of simply doing a preg_replace on some patterns. For example, the string :
### partialLoop:['partials/display.phtml',[{id:'p1',price:4.99},{id:'p2',price:12.34}]] ###
would be replaced by
<?php echo $this->partialLoop('partials/display.phtml', array(array('id'=>'p1','price'=>4.99),array('id'=>'p2','price'=>12.34))) ?>
Obviously, there would be some caching done so the page content is not rendered everytime. Does this sound good?
If not, what would be a good way of doing this? Or is there a project already being developed for doing this? (I'd like to avoid heavy third party libs and something fairly or fully compatible with ZF2 would be nice.)
Thanks.