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

    I'm using Revo 2.3.3.

    I'm having trouble figuring this one out: I have a navigation that's being generated using Wayfinder. If a PHP $_SESSION is set to 1, I need to remove the anchor on only one of the navigation items.

    So, the logic goes as this:

    • If PHP $_SESSION = 1 --> make Wayfinder list item #3 just text (no anchor)
    • Else --> make all list items anchor texts (default usage of Wayfinder)

    Can anyone point me in the right direction? I've started playing around with the rowTpl and parentRowTpl but unsuccessful so far.

    Thank you!
      Jean-Marc Buytaert (@jmbuytaert)

      MODX truly is the greatest thing that's ever happened to the Internet.
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      You'll need a custom Output Modifier to use in your rowTpl.

      Or use the If snippet in your rowTpl.

      Or use your own custom single-purpose variation of the If snippet.

      This is MODX. There are probably at least three other ways you could handle it wink
        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
        • 3749
        • 24,544 Posts
        I think you want

        if ($_SESSION['some_variable'] === '1') {
        
        }

        (or if the variable is numeric)

        if ($_SESSION['some_variable'] === 1) {
        }
        

        unless you're checking to see if *any* session is set, in which case it would be

        if (isset($_SESSION)) {
        
        }
        


        For a custom output modifier, I believe the part inside the brackets would be:

        return substr($input, 0, strpos($input, '#'));


        Assuming that you call the custom output modifier snippet RemoveAnchor, the tag in the Tpl chunk would be something like:

        <a href="[[+wf.link:RemoveAnchor]]">





          Did I help you? Buy me a beer
          Get my Book: MODX:The Official Guide
          MODX info for everyone: http://bobsguides.com/modx.html
          My MODX Extras
          Bob's Guides is now hosted at A2 MODX Hosting