Hi,
I have a Migx running on a page which outputs a gallery of youtube videos to watch.
It allows the user to add a title, and youtube id, and the tpl chunk outputs a nice thumbnail image, and a link to a modal popup window to view the video on the page.
Occasionally, I need to have more than one video within the thumbnail (because they belong to the same campaign) so inside my tpl chunk I have this:
[[+tv.YouTubeID2:notempty=`
<li class="videopage">
<a href="[[~[[+id]]]]" title="[[+pagetitle]]">
<div style="background:url(
http://img.youtube.com/vi/[[+tv.YouTubeID]]/0.jpg) no-repeat center / cover;"></div>
<p>[[+publishedon:strtotime:date=`%b %Y`]]</p>
<h2>[[+longtitle:ellipsis=`27`]]</h2>
<span><p>Watch:</p><h3>“[[+longtitle]]”</h3></span>
</a>
</li>
`:default=`
<li>
<a href="
http://youtube.com/watch?v=[[+tv.YouTubeID]]?&autoplay=1&iframe=true&width=900&height=500" rel="prettyPhoto" title="[[+pagetitle]]">
<div style="background:url(
http://img.youtube.com/vi/[[+tv.YouTubeID]]/0.jpg) no-repeat center / cover;"></div>
<p>[[+publishedon:strtotime:date=`%b %Y`]]</p>
<h2>[[+longtitle:ellipsis=`27`]]</h2>
<span><p>Watch:</p><h3>“[[+longtitle]]”</h3></span>
</a>
</li>
`]]
So what this is doing is outputting the first <li> if there is a second youtube ID entered, but if just one is entered, use the default and show the popup.
This probably isn't the most efficient code, but it does work.
But now, there are more variables coming into the pot, which i think is beyond my simplistic code.
Now, within the galelry there could be:
A: 1 video
B: 2 or more videos
C: A link to an external page
D: A link to a downloadable PDF file
But they all need to appear within the same gallery.
Obviously I need to use different tpls based on whether the user chooses A, B, C, or D.
I'm thinking of having a <select> menu in the backend, where i select A, B, C or D - and based on THAT selection, use a different TPL - but I have no idea how to go about this - and am worried that I'm going to have hundreds of TVs to cover all my bases!!
Any ideas on a more suitable and manageable process for this?
Thanks so much!
Andy