Welcome Guest, Not a member yet? Register   Sign In
How would you do this? Template loader system (dynamically create form)
#1

[eluser]otherjohn[/eluser]
Hi all,
I am working on a SaaS CMS system and want to give designers the ability to dynamically add certain items (like a banner image) to the design without coding it into the CMS, so here is my thoughts. Please tell me your thoughts on this an any suggestions:

On the CMS Admin side:
Code:
All pages have the standard fields showing (title, content, metadata, etc).
No extra fields are shown if they are not used in the sites template/design

On the Design/Template side:
Code:
When template is uploaded it is scanned for special tags
{{CUSTOM:Banner id="my_custom_banner" formtext="Enter your page header here" width="500" height="200" allowed="jpg,gif,png" }}
When a page in the CMS side selects this template for use, it will automaticlly create a form field in the page editor (in this case a banner/image manager).
These special tags would be from a library of custom premade functions.

This allows designers to add all sorts of customization to their designs without programming

I am thinking when the user saves the page, it would go into a generic blob field in the db as a serialized name:value item.
For example in this case it would probably look like :
Code:
{banner:{id:'my_custom_banner',value:'/somelink/mybanner.jpg'}

When the page is rendered the template parser would pull from that custom field.

Does this sound like it would work. Do you think this is efficient? Can anyone suggest better ways?
Thanks!
#2

[eluser]oldmatt[/eluser]
I have thought about different ways of accomplishing that. But I always end up dropping it and just using the same old way I always do.

I use on template file and pass variable in from the controllers and then plug them in in the view.
#3

[eluser]IgnitedCoder[/eluser]
@otherjohn

I think is is elegant but you might be better off storing those details as XML... for one thing managing and changing an XML template is easier than altering a a key:value pair string. Plus you could convert the XML to JSON fairly easily. Additionally with XML you could potentially query the blob field using xpath etc.

My 2 cents.

Brendan
#4

[eluser]oldmatt[/eluser]
What I mean is I use various view files as page fragments, then use a variables to let the controller know which fragment to use.

I believe the technique is discussed here:
http://ellislab.com/forums/viewthread/124268/




Theme © iAndrew 2016 - Forum software by © MyBB