Bear with me because I’m new to this...
I’ve set up my first MODx site as a blog. I want to add video so I made a template variable called "video" that gives a URL of a .flv flash video I’ve uploaded. On the main page I made a template and I used Ditto to pull in the most recent page to display it as a "post" at the top of the page. I styled this Ditto content with a tpl chunk. Below that I used Ditto to call the next 4 pages in reverse chronological order in blog fashion. I styled this Ditto content with a different tpl to fit my design. Works perfectly and easily. I made all the secondary pages work on a different template that shows each page as a single post. The Ditto tpls contains a snippet (uncached) that’s conditional and calls a chunk that uses the user entered TV "video" and applies the necessary styling and Javascript for Flowplayer to play the video. No TV "video" and the chunk doesn’t load.
This works flawlessly on the single pages, but not at all on the main page.I had thought that the Ditto call would pull in the template varible from it’s own page and execute my snippet if required on each separate instance ? It seems that this isn’t the case. It looks like the TV only comes from the main page itself.
How do I have each Ditto call retain it’s own TV and execute my snippet ? If 3 of my posts out of 5 have video, I’d like them to all show up on the main page.
The snippet [!video_variable!]:
<?php
$output=’’;
$tvValue=$modx->getTemplateVarOutput(’video’,$modx->documentIdentifier);
if($tvValue[’video’]!=’’) $output.=’{{insert_video}}’;
return $output;
?>
The chunk that inserts video {{insert_video}}:
<div class="alignright">
<a href="[*video*]" style="display:block;width:320px;height:260px;" id="player"></a>
<script language="JavaScript">flowplayer("player", "
http://mysite/assets/video/flowplayer-3.1.4.swf");</script>
</div>
Ditto chunk tpl:
<div class="post">
<div class="post_date">[+date+]</div>
<div class="post_title"><span>[+title+]</span></div>
<div class="author">Written by: [+author+]</div>
[!video_variable!]
[+content+]
</div>