We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 31966
    • 2 Posts
    warrenonline Reply #1, 17 years ago
    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>
      • 4172
      • 5,888 Posts
      Ok,

      in your ditto-chunk you have to call TV-placeholders with [+video+], not [*video*] <- this calls the TV of your resource where you are.
      you can try to use both, if you need this chunk in your ditto-tpl and directly on your page and only one of these placeholders has content:

      <a href="[*video*][+video+]" style="display:block;width:320px;height:260px;" id="player"></a>


      then, if you want to call datas in ditto from ditto-documents, you have to set this id as a parameter to your snippet-call:
      [!video_variable? &docid=`[+id+]` !]

      then in your snippet:
      $tvValue=$modx->getTemplateVarOutput('video',$docid);


      but you can also use phx in your chunk for that:

      [+video:isnot=``:then=`{{insert_video}}`+]


        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 31966
        • 2 Posts
        warrenonline Reply #3, 17 years ago
        Thanks for your time helping me out with this. This solution worked and had the video players show up in the right spot on all the pages and disappear where there was no video. This time it loaded the player with no issue, but the TV "video" didn’t seem to come through. It links and plays the video on the single page, but not the page with the Ditto.

        It looks like I can simplify this a lot by using PHx ? I can use PHx to check for the TV and display if it’s there ? I’ll have a look at this today.

        Thanks again !

        ***Edit***

        I installed the PHx plugin and added the one line as recommended by Bruno17. Thanks Bruno ! This solved the problem I was having with a much more simple and elegant solution. I’m new to MODx, but I’m fairly impressed so far. I accomplished in one day with MODx what it took me a couple of weeks and fighting with Drupal before I finally gave up.
          • 15001
          • 697 Posts
          Hi,

          This trick could be helpful.

          In some Ditto template, I observed that a custom TV of child documents could be diplayed as [*custom_tv*] but not as [+custom_tv+], the later being blank.
          Moreover, there was in the Ditto template a snippet call that had to be uncached and to which the custom TV had to be passed as parameter. And this was not working. [*custom_tv*] was not evaluated as snippet parameter.

          This article totally solved the problem:
          http://modxrules.com/articles/take-advantage-of-dittos-file-property

          Now, I use a cached Ditto call, with the template in a file.
          The custom TV is now recognized as placeholder [+custom_tv+] and I can pass it as parameter to a snippet call located in the Ditto template.

          You must put at least one placeholder in the Ditto chunk. But this can be the one passed as parameter to the snippet call placed inside the Ditto template.

          Hope this helps.

          J.
            • 19246
            • 1 Posts
            good templates