We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 32678
    • 290 Posts
    I’m using LinkToThis to provide a ’related galleries’ feature on a gallery website. The user enters comma-delimited page IDs into a text box. The output of the snippet, with no modification, is the URL alias for the corresponding document. I’d like the output to be the Document Name (document tree). I’m not a programmer and am unsure how to alter the snippet’s PHP file to accomplish this. Any input from the community would be greatly appreciated. Don’t think this would influence any resolution, but I’m using evo 1.04 and php 5.1.44.

    Thanks
      • 4310
      • 2,310 Posts
      Looking at the snippet code you should get in the html source code:
      <ul>
      for each id : <li><a href="your-alias.html">doc longtitle</a></li>
      </ul>
      Isn’t that what you see?
      Do you have a link?
        • 32678
        • 290 Posts
        Yes, that’s what I see. I’d like to swap doc longtitle with document name, as follows: <li><a href="your-alias.html">document name</a></li>

        Any thoughts on how to modify the code to swap your-alias for Document Name?

        Thanks
          • 4310
          • 2,310 Posts
          Untested, so backup first!
          <?php
          $docID = (isset($docID)) ? $docID : $modx->documentIdentifier;
          if(isset($target)) {
          $tvoutId = $modx->getTemplateVarOutput($target, $docID,'1');
          }
          else {
          $output = '<p><b>ERROR</b>: &target is missing</p>';
          }
          $linkclass =  isset($linkclass) ? $linkclass : 'linktothis';
          if($tvoutId[$target]!='') {
          $output = '<ul class="'.$linkclass.'">';
          $vary = explode(",",$tvoutId[$target]);
          for($n=0;$n<sizeof($vary);$n++) {
          $title = $modx->getPageInfo($vary[$n], 1, 'pagetitle');
          $output .=  '<li><a href="'.$modx->makeUrl($vary[$n]).'">'.$title['pagetitle'].'</a></li>';
              }
          $output.= '</ul>';
          }
          return $output;
            • 32678
            • 290 Posts
            Thanks - simple change to make after seeing it. However, I tried a couple different placeholders with no success - menutitle, longtitle. For whatever reason, only pagetitle seems to work.