We launched new forums in March 2019β€”join us there. In a hurry for help with your website? Get Help Now!
    • 15076
    • 43 Posts
    Hi all,

    I am using wayfinder 2.0 on evo.

    I want to create a menu that displays the start item and places a small image in front of the active item.
    So I created a hereTpl and a startItemTpl. I use a table to put them in to align them nicely and display a top line above each item, and add a empty field last to create the feeling every field has a top and bottom line.

    I also added a little bit of code to the snippet, to have an extra parameter to let wayfinder travel up as long as a document has a parent. On this way I always have the same view of wayfinder on whatever subitem I am.

    The problem is that the start item does not get the image, while any other selected item does get it. Does anyone know how I can solve this?


    Here are my templates:

    rowTpl:
    <tr>
        <td align="center" > </td>
         <td><a href="[+wf.link+]" title="[+wf.title+]" [+wf.attributes+]>[+wf.linktext+]</a></td>
         [+wf.wrapper+]
    </tr>
    


    hereTpl:
    <tr>
        <td align="center" ><img src="assets/images/pijl.gif" alt="pijl"></td>
         <td><a href="[+wf.link+]" title="[+wf.title+]" [+wf.attributes+]>[+wf.linktext+]</a></td>
         [+wf.wrapper+]
    </tr>
    


    startItemtpl:
    <tr>
        <td align="center"> </td>
         <td><a href="[+wf.link+]" title="[+wf.title+]" [+wf.attributes+]>[+wf.linktext+]</a></td>
         [+wf.wrapper+]
    </tr>
    



    Custom code:
    //extra part to travel up to start id that doesnt have a parent. need $extra=1 to be used
    
    if($extra == 1) {
    $id = $startId;
    $parent = $modx->getParent($id, 0, 'id');
    if($parent['id'] != "") {
    
    $loop=true;
    while($loop) {
    
    if($modx->getParent($parent['id'], 0,'id') != "") {
        $parent = $modx->getParent($parent['id'], 0, 'id');
    }
    else {
    $loop = false;
    }
    }
    }
    else {
        $parent['id'] = $id;
    }
    $startId = $parent['id'];
    }
    


    finally my wayfinder call:

    [!Wayfinder? &startId=`[*id*]` &extra=`1` &outerTpl=`wfoutertpl` &rowTpl=`wfrowtpl` &startItemTpl=`wfstartitemtpl` &hereTpl=`wfrowheretpl` &level=`1` &displayStart='TRUE' &parentRowHereTpl=`wfparentrowheretpl` !]


    Thanks in advance,

    Jurrian

      • 28042 β˜† A M B β˜†
      • 24,524 Posts
      The startItem was never intended to be a part of the menu, but a header for the menu. To actually make it a part of the menu takes some fancy manipulation of your startItemTpl and outerTpl. Look at the View Source of your page to see what is actually being generated, and think about how the tpls need to work together to get the actual menu structure that you want.

      For example, the startItemTpl can start the outer UL tags:
      <ul [+wf.classes+]>
      ...
      [+wf.wrapper+]

      While your outerTpl will skip the starting UL tag and just provide the ending tag:
      [+wf.wrapper+]
      </ul>

      Now the whole menu structure will be one list, as long as the rest of your startItemTpl matches your rowTpl structure and placeholders. Since it’s the unique startItem, you can give the <li> tag for it an ID for styling purposes.
        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