Welcome Guest, Not a member yet? Register   Sign In
Database Table as Website Template
#1

[eluser]seanloving[/eluser]
I have defined a website template as a database table. Here is how it works:

Each field in the table defines a content region of a final page. In fact, each field name in the database table defines exactly one region name within the page view. Furthermore, the order of the field names in the database table defines the order of the regions in the page view.

Each record in the table specifies a unique web page, with unique content stored in each region of the requested table record (web page request).

With a small bit of magic in the controller section, a la the _remap() function, my ONE AND ONLY view file has simplified to this single line of code:

Code:
<?php foreach($tablerecord as $region) echo $region; ?>

But for some reason having such a simple view file is screaming at me to take a closer look. It seems like something must be wrong, yet it works.

I was wondering what others thought about this approach. Thanks for any opinions.

--Sean Loving

p.s. I am slightly aware of *some* of the perils of storing user-generated code inside a database, but I don't think I'm doing that here. I have already read these threads too:

http://ellislab.com/forums/viewthread/80517/
http://ellislab.com/forums/viewthread/82053
#2

[eluser]InsiteFX[/eluser]
Well what it is it screaming to you??????

Need more input Need more input there johnny five...

Enjoy
InsiteFX
#3

[eluser]seanloving[/eluser]
Screaming: while looking through other approaches to templates, I see that a view (file) typically provides the basic website structure. In this approach however, both structure and content derive from the model. Just wondering if there are any major warnings about that. Regardless, I've been pushing ahead and plan to post some code (more info) in a couple days. Anyway, thanks for any InsiteFX you may have. --johnny five
#4

[eluser]jedd[/eluser]
So all your CSS references - what about your CSS itself? - are stored in the DB?

It's an interesting idea, but I think I'd find it cumbersome. For designers used to handling actual bits of HTML (or things that at least look like a bit like HTML) it might be stressful for the poor dears.

I think the 'model producing HTML' isn't a huge concern here - you're just abstracting the layout down a level, forcing it into the DB proper, which I don't see as theoretically bad, just probably bad from a practical point of view.




Theme © iAndrew 2016 - Forum software by © MyBB