Welcome Guest, Not a member yet? Register   Sign In
Database driven templating system
#1

[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
#2

[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...
#3

[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
#4

[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. :-)
#5

[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.
#6

[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.
#7

[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.
#8

[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
#9

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

[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.




Theme © iAndrew 2016 - Forum software by © MyBB