We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 1526
    • 72 Posts
    I'm collecting exhibitions' data with DITTO.
    For each exhibition I have a resource with special template variables (year, title, curator, place… ). My output will be a table ordered by YEAR in the first cell of the rows.
    I wish to show only the first cell a year appears, and hide the copies, something like:
    <TD rowspan="{{numberOfRepetitions}}">

    Here's a static sample of my desiderata: http://ellynagaoka.it/STATIC/pages/biography.html
    How can I do it?
    Thank you

    This question has been answered by kp52. See the first response.

      MODx evo 1.5~1.6 ✪ Apache v 2.2.22 ✪ PHP v 5.3.10 ✪ MySQL v 5.1.61
      <°'iiii);
      • 19369
      • 1,098 Posts
      I don't know if it is possible to make this only with Ditto, you may need to write a custom snippet.

      I know there is a snippet (Reflect) which generate archives by interacting with Ditto, usually it is preinstalled on MODX Evolution. I have never used it though, so I am not sure if it is what you are looking for. There was a tutorial of Reflect in the Ditto website, however it is no longer available online, I have only found this cheatsheet: http://www.scribd.com/doc/55919355/MODx-Ditto-and-Reflect-Cheatsheet-v1-2
      • discuss.answer
        • 16278
        • 928 Posts
        I've done somthing similar using a PHx modifier to set a placeholder for the column where repeats are to be avoided, outputting a non-breaking space if the current value is the same as the value of the placeholder (see http://www.borehamwoodbrass.org.uk/people.html)

        The Ditto tpl chunk reads:
        <tr><th>[+bwPosition:repeat=`[+lastPosition+]`+]</th> <td>[+hidemenu:is=`0`:then=`<a href="[~[+id+]~]">[+pagetitle+] »»</a>`:else=`[+pagetitle+]`+]</td></tr>
        


        and the PHx modifier is a snippet called phx:repeat
        <?php
        // phx:repeat
        if ($output == $options) {
        	$result = ' ';
        } else {
        	$result = $output;
        }
        $modx->setPlaceholder('lastPosition', $output);
        
        return $result;
        ?>
        


        :) KP

          • 1526
          • 72 Posts
          Thank you very much
            MODx evo 1.5~1.6 ✪ Apache v 2.2.22 ✪ PHP v 5.3.10 ✪ MySQL v 5.1.61
            <°'iiii);
            • 1526
            • 72 Posts
            Just to clarify (in case someone else needs the same code) if the repeating placeholder in the Ditto call to suppress is
            [+eventDate+]
            it becomes:
            [+eventDate:repeat=`[+lastPosition+]`+]

            Then correct the snippet with a html-non-breaking-space in place of 'Â ' which is an error of the present forum software.
            Actually, this doesn't generate a colspan as in the title of the post, but just makes the placeholder empty if it's equal to the previous. So this is not limited to table rows (I'm switching my output to list).
            Quote from: kp52 at Mar 27, 2012, 06:33 AM

            The Ditto tpl chunk reads:
            <tr><th>[+bwPosition:repeat=`[+lastPosition+]`+]</th> <td>[+hidemenu:is=`0`:then=`<a href="[~[+id+]~]">[+pagetitle+] »»</a>`:else=`[+pagetitle+]`+]</td></tr>
            


            and the PHx modifier is a snippet called phx:repeat
            <?php
            // phx:repeat
            if ($output == $options) {
            	$result = ' ';
            } else {
            	$result = $output;
            }
            $modx->setPlaceholder('lastPosition', $output);
            
            return $result;
            ?>
            


            :) KP

            [ed. note: andrearicci last edited this post 14 years, 6 months ago.]
              MODx evo 1.5~1.6 ✪ Apache v 2.2.22 ✪ PHP v 5.3.10 ✪ MySQL v 5.1.61
              <°'iiii);
              • 1526
              • 72 Posts
              A semantic variant:
              to keep the value in the table, and just hide it through CSS, I changed the ditto call to:
              <td [+eventDate:hiderepeat=`[+hidestyle+]`+]>[+eventDate+]</td>
              (of course you can use a <span> or whatever tag to apply the style)
              and the snippet (wich new name is phx:hiderepeat):
              <?php
              // phx:hiderepeat (https://forums.modx.com/thread/modify?post=418124)
              if ($output == $options) {
                  $result = 'style="visibility:hidden;"';
              } else {
                  $result = '';
              }
              $modx->setPlaceholder('hidestyle', $output);
              return $result;
              ?>

              I wanted that to keep all tabular data with their value.
              I love when I understand what's going on and can edit and share it!
                MODx evo 1.5~1.6 ✪ Apache v 2.2.22 ✪ PHP v 5.3.10 ✪ MySQL v 5.1.61
                <°'iiii);