We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 31311
    • 3 Posts
    Hi hopefully this will be an easy one for someone to solve. I’m using the default wayfinder call of
    [[Wayfinder? &startId=`0`  &level=`1`]]
    to produce a site navigation menu. I’m trying to have the menu titles wrapped in span tags like
    <a href="#" title="menutitle"><span>menutitle</span></a>


    Unfortunately, I have no idea how write the wayfinder call to do this and can’t seem to find any examples in any of the docs etc.

    If anyone can tell me if this is possible, and if so, how? I’d be most grateful.
      • 36404
      • 307 Posts
      hi,

      in order to do this you’ll have to use either a chunk or a config file to tell wayfinder what html to output

      being a confg file guy, i’ll tell you how to do this with a config file... but it’s the same with chunks

      - add &config=`virtual` in your way finder call
      - go to the assets/snippets/wayfinder/configs diretory and create a file you’ll name virtual.config.php (as you can see, same name as what you used in wayfinder call, doesn’t have to be virtual :p)
      - you have a lot of config examples in the directory but well, yours could be something like that
      <?php
      	
      	$level = 2; //this and all what follows is up to you
      	$hereClass = 'active'; 
      	$firstClass = 'first'; 
      	$lastClass = 'last';
      	
      	$outerTpl = '@CODE:<ul id="nav">
      		[+wf.wrapper+]
      	</ul>'; //id="nav" can be what you want an id a class or nothing
      	
      	$innerTpl = '@CODE:<ul>
      		[+wf.wrapper+]
      	</ul>';
      	
      	$rowTpl = '@CODE:<li[+wf.classes+]><a href="[+wf.link+]" title="[+wf.title+]"><span>[+wf.linktext+]</span></a>[+wf.wrapper+]</li>'; //here it is !!!
      	
      ?>
      


      done smiley

      have swing
        réfléchir avant d'agir
        • 31311
        • 3 Posts
        Worked a treat, Thank-you so much for that, really appreciated.

        Jason.
          • 33968
          • 863 Posts
          To do it with a chunk you would just create a new chunk called rowTpl and insert the following:
          <li[+wf.classes+]><a href="[+wf.link+]" title="[+wf.title+]"><span>[+wf.linktext+]</span></a>[+wf.wrapper+]</li>
          

          and change your snippet call to:
          [[Wayfinder? &startId=`0`  &level=`1` &rowTpl=`rowTpl`]]
          


          That said, I *hate* seeing additional markup for styling purposes undecided

          I don’t know what you’re trying to achieve, but do you really need to insert those spans?
          The titles are already nested inside both <li> and <a> elements which should give you plenty to style up with your css.