• Wayfinder shows private menu component after logout#

  • danschaefer Reply #1, 4 months ago

    Reply
    Is there something special I should do to Wayfinder so that it stops showing hidden pages AFTER a user has logged out? Hidden menu does NOT show BEFORE the user logs in. That's good. It DOES show AFTER the user has logged in. But after the user logs out, the menu item continues to show. Clicking on it does not display the hidden page (it defaults to the home page), but it's annoying that this menu item continues to show after logout.

    Using Revo 2.0.8-pl, wayfinder version 2.3.3.

    Thanks,
    Dan


  • danschaefer Reply #2, 4 months ago

    Reply
    Nevermind. I think I figured it out. Wayfinder was caching results, so menu items that did show up when the user was logged in continued to show up after the user logged out. Made a simple replacement:

    FROM [[Wayfinder? ....
    TO [[!Wayfinder? ....

    -Dan


  • BobRay Reply #3, 4 months ago

    Reply
    I'm not positive that this will work, but I think you might be able to speed things up by putting the uncached Wayfinder tag (and nothing else) in two separate chunks called "LoggedIn" and "NotLoggedIn" and using a snippet to display the appropriate chunk:

    [[!ShowMenu]]



    <?php
    /*ShowMenu snippet */
    
         $chunk = $modx->user->hasSessionContext($modx->context->get('key'))  ? 'LoggedIn' : 'NotLoggedIn';
    
    return $modx->getChunk($chunk);
    


    That way, the two menus would be cached and Wayfinder wouldn't have to recreate them on every page visit.


    ---------------------------------------------------------------------------------------------------------------
    PLEASE, PLEASE specify the version of MODX you are using . . . PLEASE!
    MODx info for everyone: http://bobsguides.com/MODx.html


  • dtschaefer Reply #4, 4 months ago

    Reply
    Thanks for the feedback Bob.

    In several places of the code, I already split it out into two different chunks depending on whether or not the user is logged in. I didn't think I had to do it for Wayfinder as well ... but in hindsight, I should have thought of it and implemented it this way. Fortunately, it's not too late to make the change.

    BTW: I'm enjoying your new book. :-)

    Dan


  • BobRay Reply #5, 4 months ago

    Reply
    Thanks for buying the book.

    ---------------------------------------------------------------------------------------------------------------
    PLEASE, PLEASE specify the version of MODX you are using . . . PLEASE!
    MODx info for everyone: http://bobsguides.com/MODx.html