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

    I’m currently coding my menu with wayfinder.

    All regular links would be
    <a href="link">Title</a>

    but I would like my active menu item to be
    <h2>Title</h2>


    and my active item should appear BEFORE the other <a> links

    So I’d get
    <nav>
      <h2>Current Page Title</h2>
        <a href="link">Title</a>
        <a href="link">Title</a>
        <a href="link">Title</a>
    </nav>
    



    Is this possible with wayfinder?
      • 15200
      • 56 Posts
      Ok, already found how to give the active menu item a different template

      &hereTpl=`chunckNameOfTemplate`


      chunck:
      <h2>[[+wf.linktext]]</h2>


      Any help on how to put the active item first in the source code order?

      So if my menu would be, for example:
      Home About Contact

      and the about page is being visited

      The menu would be:
      <nav>
        <h2>About</h2>
        <a href="/home">Home</a>
        <a href="/contact">Contact</a>
      </nav>
      
        • 22427
        • 793 Posts
        Just precede the Wayfinder call by a simple
        <h2>[[*pagetitle]]</h2>
        Now you only need to suppress the active item from the Wayfinder call to follow.
        Define in your [tt]CSS[/tt] a class [tt]hidden[/tt] like that:
        .hidden {
            display: none;
        }

        Then use the [tt]&hereClass[/tt] parameter in your Wayfinder call:
        [[!Wayfinder? &startId=`3` &level=`1` &hereClass=`hidden`]]

        That should do it (with the correct value for [tt]&startId[/tt] , of course).
          • 15200
          • 56 Posts
          Ok, that will work

          I can also use an empty chunk for the the &hereTpl.

          I’m still thinking about whether to use the <h2> inside the <nav> element or outside.
          I’m going to think about which one would be more semantically correct.


          Thank you for your answer, it will be the solution I implement, unless something better comes along.

          So if anyone has an idea how to alter the position of the active menuitem in the list, please let me know wink

          Thanks ottogal!
            • 32699 ☆ A M B ☆
            • 427 Posts
            Not really understanding why you would want to have the menu constantly changing. People tend to get lost and leave with that sort of thing.

            Why not simply use a tpl for the active or here links remove the <a href.... and use a bold or bolder style
              Get your copy of MODX Revolution Building the Web Your Way http://www.sanitypress.com/books/modx-revolution-building-the-web-your-way.html

              Check out my MODX || xPDO resources here: http://www.shawnwilkerson.com
              • 33968
              • 863 Posts
              What about:
              &excludeDocs=`[[*id]]`
              

              Which will keep the current page out of your menu, and you can use [[*pagetitle]] wherever you want smiley

              Quote from: K?! at Jun 08, 2011, 07:49 AM

              I’m still thinking about whether to use the <h2> inside the <nav> element or outside.
              I’m going to think about which one would be more semantically correct.
              Semantically speaking, a heading is not part of your navigation so I would place it outside the nav element. That’s my opinion though, I would love w3c to release a definitive list of the ’correct’ way to structure html5 tags...if that will ever be agreed on!