Welcome Guest, Not a member yet? Register   Sign In
CMS - parse a gallery from view, from database-stored content?

I am building a CMS that will store pages in DB like this:

- id (numeric)
- page_title (Shocking! Mother Parses Child!)
- page_title_url_friendly (mother_parses_child)
- page_content (entered by the client trough FCKEditor,
  stored with HTML tags in the database,
  cleaned of dangerous tags like <?php, ?>)

In the page_content (stored in DB), I would like the client to enter this:

<p>Some html</p>
<p>Some more html</p>

I will send the contents of page_content via a controller to a view. When it is displayed in a view, it should be parsed like this:

- run a DB query on the database (get all rows with "gallery_name" from some table to get filenames for this gallery)
- format the array into html (add some <li><img...> tags around the filenames from DB)
- replace {gallery[...]} with this html, leaving the top and bottom html around the gallery of course, like this:

<p>Some html</p>
<div id="gallery">
<li><img src="images/path_from_database01.jpg"></li>
<li><img src="images/path_from_database02.jpg"></li>
<p>Some more html</p>

My thoughts:

- if I knew which gallery the client wants to display, I could prepare the file list in the controller (calling a model) and add some html around it (with a helper function). But I don't know this at the controller stage, unless I search for {gallery} in the whole contents ... this seems painful, plus the client could add more galleries between his HTML contents.

- I tried parsers that work from views, but the content isn't in my view, it's in a variable that only shows up on the finally processed page...

Thank you for ANY help, this has really been bugging me and it would make my CMS very simple to modularize (I would program some HTML-injecting buttons into FCKEditor for adding modules anywhere inside the content).

Messages In This Thread
CMS - parse a gallery from view, from database-stored content? - by El Forum - 08-13-2009, 10:41 AM

Theme © iAndrew 2016 - Forum software by © MyBB