We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 26931
    • 2,314 Posts
    Hi there,

    the URL of a weblink in a Ditto listing will point to the Weblink itself, instead of the Ressource the weblink is aiming at

    lets say you got a weblink "get in touch" (alias "get-in-touch") which will point to your contact (alias "contact") page ...Ditto will display the weblink’s href as .../get-in-touch.html instead of .../contact.html

    Wayfinder handles this differently, it will use ".../contact.html" as href
    The latest version of Wayfinder uses the URL in the weblink’s content directly, thus the URL in the menu is that of the desired page (internal to your MODx installation or to an external site) instead of using the URL to the weblink document and requiring the parser to redirect.
    -> http://wiki.modxcms.com/index.php/What_Is_A_Weblink

    is there a workaround for Ditto to get this behaviour (other than allowing duplicate aliases, or using Wayfinder)?

    thanks, j
      • 1122
      • 209 Posts
      <?php
      /*
       * Ditto Extender: symlink.extender.inc.php
       * Links document or follows weblink
       * Released under the terms of General Public License
       * Copyright (c) 2010 Aleksander Maksymiuk, http://setpro.pl/
      
       * Parameters: no parameters required
       * Sample usage: display main menu (i.e. first level of document's tree)
       *  [[Ditto? &parents=`0` &depth=`1` &display=`all` &tpl=`menu-lev-1` &orderBy=`menuindex ASC` &extenders=`symlink`]]
       *  sample "menu-lev-1" template:
       *   <p><a href="[+symlink+]">[+pagetitle+]</a></p>
       * Notice: [+symlink+] placeholder is substituted with either a link to regular document or a target that weblink points to
       */
      
      $placeholders['symlink'] = array('id,type,content', 'setSymlinkPlaceholder');
      
      if (!function_exists('setSymlinkPlaceholder')) {
        function setSymlinkPlaceholder($resource) {
          return ($resource['type'] == 'reference' ?
            (is_numeric($resource['content']) ?
              '[~' . $resource['content'] . '~]' :
              $resource['content']
            ) :
            '[~' . $resource['id'] . '~]'
          );
        }
      }
      
      ?>
      
        • 26931
        • 2,314 Posts
        alik - you’re the man!!! laugh thank you!
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          Very nice! Ditto extenders would be a very useful tool to add to anyone’s kit.

          A bit more background on weblinks and Wayfinder http://sottwell.com/article-weblinks.html
            Studying MODX in the desert - http://sottwell.com
            Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
            Join the Slack Community - http://modx.org