views:

64

answers:

2

I'm building a very basic CMS for a specific project that contains numerous functions such as get_menu(), get_title(), get_recent(), etc. However, I want to be able to store templates, which would be echoed during page load, that contain said functions in the MySQL database.

Doing a str_replace for each possible function would be a pita and I realize that using eval() is at times dangerous. Is there a better, more efficient way to go about doing this? I'm pretty sure it can be done as this is how templates are set up in Textpattern.

+3  A: 

For the reason you mention, I think you're better off using Smarty or some other templating language. If you want to load your templates dynamically, just store the filenames instead.

Dana the Sane
+1  A: 

Smarty is one popular option. I recommend rolling your own (sorry, you're going to need PHP external to MySQL for this). Some suggestions here: http://stackoverflow.com/questions/1064916/how-should-i-design-my-code/1064946#1064946

Dinah