tags:

views:

440

answers:

1

I'm currently building a site that allows previewing photos and videos using Shadowbox. I'm also using the jQuery Tools Scrollable tool to allows the thumbnails to be scrolled. I'm using ModX as the CMS.

I want whoever edits the page to be able to use TinyMCE as the editor, this has been OK for the photos but for the videos I want a description for each video too. I need the code to be in the following format as each of the elements for a video need to be wrapped in a div for the scrollable to work properly.

<div>
   <a href="video_preview/stupid girl.flv"><img src="images/vid.gif" alt="video 1" title="Stupid Girl" /></a>
   <h4>STUPID GIRL</h4>
   <p>Garbage perform classic hit Stupid Girl</p>
</div>
<div>
   <a href="video_preview/rehearsals.flv"><img src="images/rehearsals.jpg" alt="video 2" title="Rehearsals" /></a>
   <h4>REHEARSALS</h4>
   <p>Garbage back stage and at rehearsals</p>
</div>

Here there are 2 videos put I want to allow any number of videos to be entered. At the moment I can't get TinyMCE to generate code in this format. How do I go about doing this or is there a different way I should be looking at this. At the moment the above code section is contained within it's own Chunk

+1  A: 

I think you are going about this in the wrong manner.

Create a new folder called Videos The documents in Videos don't need to show in menu etc. Assign the documents in Videos a template in this case "videos-template"

Create template variables for that template for the following items: Movie-file, title, description.

Use the HTML you have there in a chunk, in this case "video-chunk" ie.

    <div>
   <a href="[*Movie-file*]"><img src="images/vid.gif" alt="video 1" title="Stupid Girl" /></a>
   <h4>[*title*]</h4>
   <p>[*description*]</p>
</div>

Then in a chunk use Ditto to interate through your "videos" folder with the above chunk as the template ie.

[!Ditto? &parents=`183`&orderBy=`createdon ASC` &display=`5`
  &total=`5` &tpl=`video-chunk`!]

Let me know if that makes sense but in my mind you should certainly be tackling it in a manner similar to this.

This way when the user wants to add new videos they simply create a new document in the videos folder and set the template variables.

Fishcake
Info on Ditto: http://wiki.modxcms.com/index.php/Ditto
Fishcake
I guess should say why I think this method is better...By using this approach the users can't screw up the HTML which in my experience is inevitable if they have access to do so.
Fishcake
That's great, thanks. I was looking for an iterative solution but pretty new to modx. Makes perfect sense.
Carbonara
I agree, removing access to the HTML is most important.
Carbonara
A very good structured answer. @cabonara - I would probably take this as the accepted answer
Joe