We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 4749
    • 623 Posts
    I’m using Ditto to aggregate some links and need to run another snippet in the tpl chunk. However it’s not rendering as it should. If I run it uncached it just renders the call as HTML. If I render it cached nothing shows up. The debug doesn’t give any helpful information either.

    Here’s my Ditto call:
    [!Ditto? &parents=`[*id*]` &tpl=`anchorListTpl` &sortBy=`menuindex ASC` !]


    and the chunk:
    <a href="[~[+id+]~]">[+pagetitle+]</a>[[ListBuilder? &tv=`anchorList` &docid=`[+id+]`]]


    Thanks for any insight.

    EDIT: I got it running as needed. Fairly simple mistake. Here’s the ditto call:
    [!Ditto? &parents=`[*id*]` &tpl=`anchorListTpl` &sortBy=`menuindex ASC` &hiddenFields=`anchorList`!]


    Here’s the chunk with the embedded snippet:
    <li><a href="[~[+id+]~]">[+pagetitle+]</a>[[ListBuilder? &tv=`anchorList` &docid=`[+id+]`]]</li>


    Just had to add the &hiddenFields parameter and it worked.
      The MODx has you...
      Utah Web Design
      • 4749
      • 623 Posts
      OK, I’ve got it working mostly, but it’s not pulling the data correctly. The problem is that I’m trying to create a sub menu for a menu populated by Ditto. I know, I know - use Wayfinder, right? Well, I can’t use Wayfinder in this instance. The client is making links on the Widget, Thingamabobs, and Dingle-hopper pages. Those links need to be listed as Item 1, Item 2, Item 3, Item 4. Well, the problem is that they’re being made by the client with TinyMCE and he wants anchor links to take people straight to the items (e.g., "/widgets.html#item1").

      Parent Page (Ditto menu built here)
      
      - Widgets
        -- Item 1
        -- Item 2
        -- Item 3
        -- Item 4
      
      - Thingamabobs
        -- Item 1
        -- Item 2
        -- Item 3
        -- Item 4
      
      - Dingle-hoppers
        -- Item 1
        -- Item 2
        -- Item 3
        -- Item 4
      


      Right now I’m trying to do this with a custom snippet:
      <?php
      /**
       * Convert a text with linebreaks to a html list
       * written by Roman
       */
      $chunk = isset($chunk) ? $chunk : false;
      $tv = isset($tv) ? $tv : false;
      $delimiter = isset($delimiter) ? $delimiter : "\n";
      $docid = isset($docid) ? $docid : $modx->documentObject['id'];
      
      if($tv){
      	$tvArray = $modx->getTemplateVarOutput(array($tv), $docid);
      	if(!$tvArray[$tv])
      		return;
      	
      	$text = $tvArray[$tv];
      } else if($chunk){
      	$text = $modx->getChunk($chunk);
      	if(!$text)
      		return;
      } else {
      	return;
      }
      
      $lines = explode($delimiter, $text);
      $out = '<ul>';
      foreach($lines as $line){
      	$out .= '<li>' . trim($line) . '</li>';
      }
      $out .= '</ul>';
      return $out;
      ?>


      This snippet calls on a text area tv where the links are built manually and separated by line breaks.
      <a href="/sample.html#sample1">Sample 1</a>
      <a href="/sample.html#sample2">Sample 2</a>
      <a href="/sample.html#sample3">Sample 3</a>
      


      right now I can’t refer back to the tv on the widget pages properly. Nothing renders. How can I refer to that tv with this set up? In other words - how can I reference a tv from the child to display in the parent? I think that’s all it comes down to.
        The MODx has you...
        Utah Web Design