We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 3186 ☆ A M B ☆
    • 279 Posts
    Hi all,

    I'm currently starting a project where you can register yourself. Now I would like to have a "Register" menu item that is only visible when you're not logged in as user, so when you are anonymous.

    I tried to create that with a resource group just for anonymous usergroup but didn't get that working. Does anyone have experience with this?

    Thanks in advance

    Regards, Bert
      MODX Ambassador (NL) & Professional MODX developer
      Follow me on Twitter | Visit my page on Facebook | View my code on Github | View my script posts
      MODX e-commerce solution SimpleCart
      • 33968
      • 863 Posts
      Hey Bert

      This placeholder/filter combination will return true if the user is not logged in:
      [[+modx.user.id:isnotloggedin]]
      


      Is that something you can work with?
        • 3186 ☆ A M B ☆
        • 279 Posts
        I use Wayfinder for my menus
        Wayfinder checks the permissions when you have a resource group available for a "member" usergroup and when you're not logged in or not belongs to that usergroup, the page is not being showed .. I would like to have this for the anonymous usergroup.. that the page is only visible for unknown users.. when you login the page should disappear
          MODX Ambassador (NL) & Professional MODX developer
          Follow me on Twitter | Visit my page on Facebook | View my code on Github | View my script posts
          MODX e-commerce solution SimpleCart
          • 33968
          • 863 Posts
          Ah, you kindof want the opposite behaviour for protected resources. Without modifying Wayfinder or writing your own snippet, there are two ways that first came to mind:

          1. 'hard-code' your anonymous link before or after your Wayfinder list, using the filter above to show if the user is not logged in:
          <ul>
              [[!Wayfinder .... ]]
              [[+modx.user.id:isnotloggedin:show=`[[$anonymous-chunk]]`]]
          </ul>
          // filter syntax is probably wrong!
          


          2. hide the link using css:

          Template
          // again, filter might be wrong
          // not titleOfLinks property
          <ul [[+modx.user.id:isloggedin:show=`class="logged-in"`]]>
              [[!Wayfinder... &titleOfLinks=`alias` ]]
          </ul>    
          


          RowTpl
          <li><a href="[[+wf.link]]" class="[[+wf.title]]">[[+wf.linktext]]</a>[[+wf.wrapper]]</li>
          


          CSS
          // css (change to your anonymous resource alias
          .logged-in .anonymous-resource-alias {
              display: none;
          }
          

            • 3186 ☆ A M B ☆
            • 279 Posts
            Thanks Lukas for taking time to help me out! Unfortunate your suggest is not wat I'm looking for. Wayfinder do check the permissions and my idea about the resource group is working great, I only forgot that there are some mess ups when you're logged-in in the manager also in the same browser. When I check the frontend login in an other browser then it works like a charm!

            So; what I did;

            - Create a resource group (like: Anonymous onlye)
            - Update the usergroup for the frontend members and go to "Resource group access" tab
            - Add the resource group with the right role for the right context etc.

            This works for me, but remember to check the frontend in an other browser then where you're logged-in in the manager smiley
              MODX Ambassador (NL) & Professional MODX developer
              Follow me on Twitter | Visit my page on Facebook | View my code on Github | View my script posts
              MODX e-commerce solution SimpleCart