CodeIgniter Forums
Database driven templating system - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Database driven templating system (/showthread.php?tid=7623)

Pages: 1 2


Database driven templating system - El Forum - 04-16-2008

[eluser]webdude[/eluser]
Hello

Is anyone running templates from a database? I am wanting to create something like the template system used in ExpressionEngine

Thanks

WD


Database driven templating system - El Forum - 04-16-2008

[eluser]dioony[/eluser]
i started to code such a template-system, but give it up because due to the MVC pattern i decided to have no view-elements in the database... and i think a database driven template system is not very dry. therefore i use a rails-like system: each controller has a folder and each method a view-file...

but if you're looking for something:

maybe you can use the "display_override" method and a hook to replace the expressions... for another project i used the Yield-hook (which i found here) to load various subcontent into a default-layout. there were also some expressions like {content} {menu} {footer} or something like that...

maybe this could help you...


Database driven templating system - El Forum - 04-17-2008

[eluser]webdude[/eluser]
thanks for the reply. i have just uploaded CI and am going to have a play to see what i can get working.

wd


Database driven templating system - El Forum - 04-17-2008

[eluser]Sean Murphy[/eluser]
Hey, not to be too harsh, but templates stored a DB suck. It's really, really bad for performance. But if you don't care about that, go right ahead. :-)


Database driven templating system - El Forum - 04-17-2008

[eluser]Derek Allard[/eluser]
Databases offer other advantages though. If performance is your only concern, you'd be best off building a static html page.


Database driven templating system - El Forum - 04-17-2008

[eluser]Sean Murphy[/eluser]
What are the advantages of storing templates in a DB? I can't seem to think of any. Edit: Just thought of some. :-)

Derek, you're absolutely right, static HTML yields the best performance. In most cases though, especially for people on this forum who use CI, static HTML isn't an option.

Performance should never be your only concern, but if you want to build the best products it should without fail A concern.


Database driven templating system - El Forum - 04-17-2008

[eluser]xwero[/eluser]
To get back on topic Wink The templates don't have to come from a database you can do it from files too using file_get_contents and other file functions. Once you get the content of a file in a string it isn't going to get executed.


Database driven templating system - El Forum - 04-17-2008

[eluser]webdude[/eluser]
hey guys thanks for the replies.

tbh custom tags are the most important things for me at the moment, keeping the code away from the designers is a must lol.

thanks once again.

wd


Database driven templating system - El Forum - 04-17-2008

[eluser]xwero[/eluser]
try the phptal template engine it works with attributes rather than with php like syntax.


Database driven templating system - El Forum - 04-18-2008

[eluser]esra[/eluser]
Not sure if they still do this, but the XOOPS 2.x CMS fork stored templates in a database table when they were installed, and used Cache-Lite to compile templates to a cache directory. If I recall, XOOPS could detect if a compiled template had been modified for any reason and recompile a new template if this was the case.