I have been doing a lot of work on the Wayfinder-driven menus on my site of late, and have made much progress with what I've wanted to accomplish. My latest challenge is to have a page name change based on whether the user is actively logged in to the site or not.
I created a document that is a child to another document. This page is added to a pop-up submenu by Wayfinder and am making that call un-cached. I have also set the child page as not cacheable. For the page Title and Menu Title fields (I had originally populated only the Title field) I used "[[*loginLogout]]" as the value.
I created a Template Value called loginLogout and set the Input default value to:
@EVAL if ($modx->getLoginUserID()) return 'Log Out/Profile'; else return 'Log In';
Opening a browser and browsing to my site renders the content properly. The last menu item, Members, has a pop-up menu with only one option on it: Log In. This is working as designed. Clicking either Members or Log In will bring the user to the same content and they will be allowed to enter a username and password. Successful login results in the user being returned to the site's Home page.
At this point, if you hover over Members, there are four new pages that are available (access controls), and the Login page is still listed as well. The problem is that the Login page is actually a Log In / Log Out / Profile Management page - which content is shown is decided by whether or not the user is actively logged in.
The problem is that, from the Home page, the last item on the Members submenu says "Log In" and it should say "Log Out/Profile" instead. From all of the other active pages, the last Members submenu item is correct.
Clearly, the evaluation formula works because I do get the right value being passed in many cases. But, in certain cases, it seems as if the TV is not being evaluated early enough in the process for the page to get the correct name.
Any input on this?