We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 43509
    • 24 Posts
    Hi,
    I would like Wayfinder to "color" my currently selected link... but Things don't seem to be working.
    I have just one menu level.

    Here is my Wayfinder call:

    [[Wayfinder?
    &startId=`15`
    &hereId=`[[*id]]`
    &useWeblinkUrl=`1`
    &level=`1`
    &outerTpl=`MainNavigationOuter`
    &firstClass=``
    &lastClass=``
    &hereClass=`active`
    ]]

    I'am trying this way to add an "active" class to the currently selected "<li>".
    Why does not it work?


    With &debug=`true` I get two errors:

    1) Warning: Illegal offset type in ..\core\components\wayfinder\wayfinder.class.php on line 350
    2) Warning: strpos() expects parameter 1 to be string, array given in ..\core\components\wayfinder\wayfinder.class.php on line 926

    Thanx! [ed. note: matpiaz last edited this post 11 years ago.]
      • 42562
      • 1,145 Posts
      donshakespeare Reply #2, 11 years ago
      Hi,

      I have something like this, and it works with the ACTIVE link styled according to my CSS.

      Make sure all your TPLs exist
      I wouldn't leave values empty as in &firstClass=``
      [[Wayfinder?
      &startId=`7`
      &level=`2`
      &outerTpl=`outerTpl`
      &innerTpl=`innerTpl`
      &rowTpl=`rowTpl`
      &hereTpl=`hereTpl`
      &contexts=`web`
      &scheme=`full`
       ]]

      I do not even need the &hereClass=`active` because it is "active" by default.
        TinymceWrapper: Complete back/frontend content solution.
        Harden your MODX site by passwording your three main folders: core, manager, connectors and renaming your assets (thank me later!)
        5 ways to sniff / hack your own sites; even with renamed/hidden folders, burst them all up, to see how secure you are not.
        • 43509
        • 24 Posts
        Actually I was using wayfinder together with weblinks, so my problem is the same addressed by this old post: http://forums.modx.com/thread/?thread=40752&page=1

        Then I solved it using a similar solution (it requires two packages: "getResourceField" and "If" snippets) as &rowTpl:

        <li[[+wf.id]] class="[[+wf.classnames]] [[!If? &subject=`[[!getResourceField? &id=`[[+wf.docid]]` &field=`content`]]` &operator=`==` &operand=`[[~[[*id]]]]` &then=`active` &else=``]]">
        	<a href="[[+wf.link]]" title="[[+wf.linktext]]" [[+wf.attributes]]>[[+wf.linktext]]</a>
        	[[+wf.wrapper]]
        </li>
        


        Obviously it requires that inside your weblink resource you declare the Weblink field (i.e. [[*content]]) as [[~id]].
          • 42562
          • 1,145 Posts
          donshakespeare Reply #4, 11 years ago
          Just as you, I have also included some logic in my WayFinder calls. But I stopped though...for efficiency sake. WayFinder is already heavy as it is
            TinymceWrapper: Complete back/frontend content solution.
            Harden your MODX site by passwording your three main folders: core, manager, connectors and renaming your assets (thank me later!)
            5 ways to sniff / hack your own sites; even with renamed/hidden folders, burst them all up, to see how secure you are not.