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

    I am using Evo 1.0.12 with the inbuilt Wayfinder 2.0.1 on a server with PHP Version 5.2.17.

    I am attempting to use Wayfinder for nested breadcrumb style browser titles.

    I found this very old but handy thread (http://forums.modx.com/thread/?thread=39689) and the resulting wiki (http://wiki.modxcms.com/index.php/Breadcrumb_navigation_with_Wayfinder) and have almost got it working.

    I just need to reverse the order.

    I have tried &sortOrder=`DESC` and &sortOrder=`ASC` but neither seem to make a difference.

    Both &sortOrder version return:
    Products - Tools - Ladders

    I would like the order to be the reverse of that - eg:
    Ladders - Tools - Products

    The website structure is like so:
    Products > Tools > Ladders

    These are the wayfinder templates etc:

    wayfinder call - {{titles-menu}}:
    [[Wayfinder? &startId=`0` &textOfLinks=`pagetitle` &sortOrder=`DESC` &outerTpl=`titles-menu-wrapper` &rowTpl=`titles-menu-row` &activeParentRowTpl=`titles-menu-row-parent` &hereTpl=`titles-menu-here`]]
    
    &outerTpl:
    [+wf.wrapper+]
    
    &rowTpl:
    {{an empty chunk with no content}}
    
    &activeParentRowTpl:
    [+wf.linktext+] - [+wf.wrapper+]
    
    &hereTpl:
    [+wf.linktext+]


    Any idea where I am going wrong?


    There is also a massive amount on space in the source code - eg:

    <title>
    
    Products - Tools - Ladders
    
    
    
    
    
    
    
    
    
    
    
    
    
     - Site name</title>


    I am inserting the titles like so:
    <title>[[if? &is=`[*longtitle*]:empty` &then=`{{titles-menu}} - [(site_name)]` &else=`[*longtitle*] - [(site_name)]`]]</title>

    Any ideas what might be causing that extra spacing?

    Thanks in advance for any help. [ed. note: nickf08 last edited this post 10 years, 4 months ago.]
      Web design Adelaide
      http://gocreate.com.au
      • 13226
      • 953 Posts
      I wrote in a forum post about doing pretty much the same as you want to, you can find it here

      The whitespace is produced via the way wayfinder has been coded together. If you take a closer look at my post you will see:
      $removeNewLines = 1;

      This helps a little, but doesn't completely get rid of all whitespace.

      Ref sort order: you will have to give it a test and try some stuff out smiley

      p.s I have this running on a site I recently built - I will have a quick look and see if the sort order can be changed easily
        • 13226
        • 953 Posts
        UPDATE:

        This works - but please test to ensure it fits what you need - I am in no way a PHP programmer

        This is a modified version of the one I posted in the other forum post, I have modified it further for the site I just built and have just modified it for your sort order problem.

        Create a new file in the folder "assets/snippets/wayfinder/configs/" and call it "title-tag.config.php", then copy and paste the following code into the new file:

        <?php
        // [[Wayfinder? &config=`title-tag`]]
        $startId = '0';
        $hideSubMenus = 1;
        $fullLink = 0;
        $selfClass = ''; 
        $hereClass = ''; 
        $firstClass = ''; 
        $lastClass = '';
        $textOfLinks  = 'pagetitle';
        $titleOfLinks = '';
        $removeNewLines = 1;
        $ignoreHidden = 1;
        
        if ($modx->config['site_start'] == $modx->documentObject['id']) {
        	$homeLink = "{$modx->config['site_name']}";
        } else {
        	$homeLink = "{$modx->config['site_name']}";
        }
        
        $outerTpl = "@CODE:[+wf.wrapper+] | {$homeLink}";
        $innerTpl = '@CODE:[+wf.wrapper+] | ';
        $rowTpl = '@CODE: '; //Do not change '@CODE: ' - it must stay exactly as it is (with the space), otherwise the breadcrumb breaks
        $activeParentRowTpl = '@CODE:[+wf.wrapper+][+wf.linktext+]';
        $hereTpl = '@CODE:[+wf.linktext+]';
        ?>

        The Wayfinder call:
        <title>[[Wayfinder? &config=`title-tag`]]</title>

        If you want the homepage to have a bespoke title you can do something like I did - I use the "if" snippet for the homepage as such:
        <title>[[if? &is=`[*id*]:is:1` &then=`[(site_name)] | [*pagetitle*]` &else=`[[Wayfinder? &config=`title-tag`]]`]]</title>
          • 21417
          • 486 Posts
          Hi and thanks iusemodx.

          That's a wonderful solution, it works perfectly.

          I forgot about the &removeNewLines option - I have never used that before. Great tip.

          Your custom config file fixes both the sorting and the whitespace.

          Thanks so much for sharing and helping.

          Keep up the great Evo work.

          ps I wonder why the sort order can't be reversed in my original attempt? Is it a bug or just a quirk etc?
            Web design Adelaide
            http://gocreate.com.au
            • 13226
            • 953 Posts
            I tried using the "sortorder" and the "sortby" whilst testing, but they didn't work

            So I changed the sort order by modifying the templates:

            My original code looks like this:
            $outerTpl = "@CODE:{$homeLink} | [+wf.wrapper+]";
            $innerTpl = '@CODE: | [+wf.wrapper+]';
            $rowTpl = '@CODE: '; //Do not change '@CODE: ' - it must stay exactly as it is (with the space), otherwise the breadcrumb breaks
            $activeParentRowTpl = '@CODE:[+wf.linktext+][+wf.wrapper+]';
            $hereTpl = '@CODE:[+wf.linktext+]';

            I modified it for your reverse order to this:
            $outerTpl = "@CODE:[+wf.wrapper+] | {$homeLink}";
            $innerTpl = '@CODE:[+wf.wrapper+] | ';
            $rowTpl = '@CODE: '; //Do not change '@CODE: ' - it must stay exactly as it is (with the space), otherwise the breadcrumb breaks
            $activeParentRowTpl = '@CODE:[+wf.wrapper+][+wf.linktext+]';
            $hereTpl = '@CODE:[+wf.linktext+]';


            I don't know why it doesn't work with the "sortorder" maybe you are right, it may be a bug, a PHPer would have to take a look smiley

            p.s Glad I could help out - Happy christmas
              • 21417
              • 486 Posts
              Thanks for clarifying iusemodx and I hope you had a great Christmas too.

              I can see the difference in your code.

              Interestingly, if I follow your lead in my original "template chunk" testing and change the order of the [+wf.linktext+] and [+wf.wrapper+] in the &activeParentRowTpl per your code above, the order reverses as expected - eg:
              &activeParentRowTpl:
              [+wf.wrapper+] - [+wf.linktext+]

              So that seems to dictate the order rather than the &sortOrder option.

              These are the final chunks etc that show in reverse order:
              wayfinder call - {{titles-menu}}:
              [[Wayfinder? &startId=`0` &textOfLinks=`pagetitle` &sortOrder=`DESC` &removeNewLines=`true` &outerTpl=`titles-menu-wrapper` &rowTpl=`titles-menu-row` &activeParentRowTpl=`titles-menu-row-parent` &hereTpl=`titles-menu-here`]]
              
              &outerTpl:
              [+wf.wrapper+]
              
              &rowTpl:
              {{an empty chunk with no content}}
              
              &activeParentRowTpl:
              [+wf.wrapper+] - [+wf.linktext+]
              
              &hereTpl:
              [+wf.linktext+]


              I will stick with your config file though because it is much neater.

              Thanks again. [ed. note: nickf08 last edited this post 10 years, 4 months ago.]
                Web design Adelaide
                http://gocreate.com.au
                • 4172
                • 5,888 Posts
                Quote from: iusemodx at Dec 24, 2013, 02:39 PM

                I don't know why it doesn't work with the "sortorder" maybe you are right, it may be a bug, a PHPer would have to take a look

                I don't think this is a bug.
                I think &sortBy and &sortDir does only affect the order of Resources inside a level, but not the order between different levels - (parent to children) vs (children to parent)
                  -------------------------------

                  you can buy me a beer, if you like MIGX

                  http://webcmsolutions.de/migx.html

                  Thanks!
                  • 21417
                  • 486 Posts
                  Ah ok, Thanks Bruno17.
                    Web design Adelaide
                    http://gocreate.com.au