We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 10457
    • 5 Posts
    Hi,
    In order to display multiple photo albums with captions I installed a noobslide carrousel into MODX Evolution (1.0.3) which worked successfully. When migrating to MODX Revolution 2.1.3 it no longer works. I’ve amended my php script for revo but still think this is where its falling down. Can anyone advise?

    Im running mootools-1.2-core.js and _class.noobSlide.packed.js

    MODX Evolution


    Php called LoadCaroussl is below. The Resources has the following TV’s attached:
    Images - called Picture01, Picture02 etc
    Caption - called Picture01Text, Picture02Text.
    To pick up the correct number of photos I added a TV called PictureCount.

    The TV’s are referenced in the Resource, the template of which has the following call [[LoadCaroussel? &imagecount=`[*PictureCount*]`]]

    <?php
    $id = $modx->documentObject[’id’];
    $pub = $modx->documentObject[’published’];

    for ($i=1; $i <= $imagecount; $i++) {
    if ( $i < 10 ) {
    $leader = ’Picture0’;
    } else {
    $leader = ’Picture’;
    }
    $pictureTV = $leader.$i;
    $picture = $modx->getTemplateVarOutput($pictureTV, $id, $pub);
    $picturetextTV = $leader.$i.’Text’;
    $picturetext = $modx->getTemplateVarOutput($picturetextTV, $id, $pub);
    echo "<div><img src=\"".$picture[$pictureTV]."\"/><h3>$picturetext[$picturetextTV]</h3></div>";
    }
    ?>



    I followed broadly the same lines in Modx Revolution using Bob’s Guides to amend the php

    Template has the identical call [[!LoadCarousel? &imagecount=`[[*PictureCount]]` ]]

    php

    <?php
    $id = $modx->resource->get(’id’);
    $doc = $modx->getObject(’modResource’, $id);

    for ($i=1; $i <= $imagecount; $i++) {
    if ( $i < 10 ) {
    $leader = ’Picture0’;
    } else {
    $leader = ’Picture’;
    }
    $pictureTV = $leader.$i;
    $picture = $doc->getTVValue((string)$pictureTV);
    $picturetextTV = $leader.$i.’Text’;
    $picturetext = $doc->getTVValue((string)$picturetextTV);
    echo "<div><img src=\"".$picture[$pictureTV]."\"/><h3>$picturetext[$picturetextTV]</h3></div>";
    }


    wierdly, this correctly picks up the number of photos - though doesn’t show the image. It gives the caption - but only the first letter......hmmm

    Can anyone tell me where I’m going wrong?

      • 33968
      • 863 Posts
      First - try to use the code tags on this forum, makes reading a bit easier!

      I think the problem is your getTVValue syntax was wrong. Try like this instead:
      <?php
      $output = '';
      $id = $modx->resource->get('id');
      
      for ($i=1; $i <= $imagecount; $i++) {
          if ( $i < 10 ) {
                 $leader = 'Picture0';
          } else {
                 $leader = 'Picture';
          }
          $pictureTV = $leader.$i;
          $picture = $modx->resource->getTVValue($pictureTV);
          $picturetextTV = $leader.$i.'Text';
          $picturetext = $modx->resource->getTVValue($picturetextTV);
          $output .= "<div><img src=\"".$picture[$pictureTV]."\"/><h3>$picturetext[$picturetextTV]</h3></div>";
      }
      return $output;
      

      Also, you do not need to call getObject again as you already have access to the current resource smiley
        • 10457
        • 5 Posts
        Dear Lucas,
        Thank you for posting a reply - I still couldn’t get it to work but found gallerifics does pretty much similar job so installed that!

        best,
        camilla