We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 31661
    • 2 Posts
    I need send to Ditto parametr starId. But i cant use static Id, because i need use this code in other dirs. So i try get Id from page by they alias and parent document.
    For example i use whis URL: /rootdir/articles/ on site. I get ID for this page by doing this:
    <?php
    // Sample usage:
    // [!getDocIdInMainDirByAlias?alias=`products`!]
    
    
    $langArray=$modx->getDocumentChildren(0);
    
    foreach ($langArray as $lang) {
     if ($modx->runSnippet('UltimateParent') == $lang['id']) {
      $mainDirArray = $modx->getDocumentChildren($lang['id']);
      foreach ($mainDirArray as $dir) {
       if ($dir['alias'] == $alias)
        return $dir['id'];
       }
     }
    }
    ?>

    It works well. Then i need Ditto to output all childrens in folder /rootdir/articles/.

    I try do [!Ditto? &startID=`{{productsDirID}}`!] - where {{productsDirID}} return id of need document.
    But result in page i see all code after startId.
    Wrong tags?
    But this code work:
    {{productsDirID}}
    [!Ditto? &startID=`{{productsDirID}}`!]

    I cant understand why it work...
    Then i try make one snippet with this code:
    <?php
    return $modx->runSnippet('Ditto', array(
    'startId' => $modx->runSnippet('getDocIdInMainDirByAlias', array('alias' => 'articles')),
    'showInMenuOnly' => '1',
    'summarize' => '3',
    'paginate' => '0',
    'tpl' => 'atricles_main_folder'
    ));
    ?>

    It dont work... "return No documents found."

    Then i try change Ditto to Wayfinder - thats works well. Why not work Ditto?
    Is it another way to send dynamic parameter to snippet?
    Thx!
      • 10226
      • 412 Posts
      This is a bit over my head, but a great implementation. Have you tried a debug output of Ditto? I didn’t know Ditto had this option, but once i learned of it, it has proven vary helpful.

      Good Luck!
        • 36805
        • 354 Posts
        Which Ditto version are you using? As far as I know as of 2.x. the parameter "startId" has been replaced by "parents" as the Documentation shows.