We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 10487 MODX Staff
    • 1,535 Posts
    Garry Nutting Reply #11, 19 years ago
    Yeah, option 1 will completely protect the pages, so if a user doesn’t have permission then they won’t be able to see the pages in the menu.

    For option 2, have you set the page to be uncachable? You need to make sure you set the page and snippet caching correctly else you’ll hit problems. I can’t really think what else would be wrong with the setup, it worked for me on a default install.
      Garry Nutting
      Senior Developer
      MODX, LLC

      Email: [email protected]
      Twitter: @garryn
      Web: modx.com
      • 20991
      • 99 Posts
      Something is not working right...

      My guess is that the Snippet is not set up right for my WebLoginSidebar?

      Maybe it’s easier if I just show the code. I’ve bolded anything I think is relevant.

      [[MemberCheck? &groups=`siteadmin, registered users` &chunk=`privateSiteNav` &ph=`MemberMenu` &debug=`true`]]
      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <html xmlns="http://www.w3.org/1999/xhtml">
      <head>
      <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
      <title>the NY network</title>
      <link rel="stylesheet" type="text/css" href="[(base_url)]assets/templates/nynetwork/css/style.css" />
      </head>
      <body>
      <div id="header">
      <div id="headercontent">
      <h1 class="smalllogo">The Network</h1>
      <div id="Navigation">
      [!Wayfinder?startId=`0`!]
      <!--- <ul>
      <li class="current"><a href="meetings.html">meeting schedule
      </a></li>
      <li><a href="members.html">members</a></li>
      <li><a href="contact.html">contact
      </a></li>
      <li><a href="events.html">events
      </a></li>
      <li><a href="newsletters.html">newsletters
      </a></li>
      <li><a href="blog.html">blog</a></li>
      </ul> --->
      </div>
      </div>
      </div>
      <div id="center">
      <div id="centercontent">
      <div id="leftcontent">
      [[Personalize? &yesChunk=`loggedIn` &noChunk=`notLoggedIn`]] <!--- [*#content*] --->
      </div>
      <div id="sidebar">
      <h2>News:</h2>
      [[Ditto? &startID=`2` &summarize=`2` &total=`20` &commentschunk=`Comments` &tpl=`nl_sidebar` &showarch=`0` &truncLen=`100` &truncSplit=`0`]]
      <div id="recentdocsctnr">
      <h2>Most Recent:</h2>
      <a name="recentdocs"></a>[[ListIndexer?LIn_root=0]] </div>
      <h2>Login:</h2>
      <div id="sidebarlogin">[!WebLogin? &tpl=`FormLogin` &loginhomeid=`[(site_start)]`!]</div>
      <h2>Meta:</h2>
      <p><a href="http://validator.w3.org/check/referer" title="This page validates as XHTML 1.0 Transitional">Valid <abbr title="eXtensible HyperText Markup Language">XHTML</abbr></a></p>
      <p><a href="http://jigsaw.w3.org/css-validator/check/referer" title="This page uses valid Cascading Stylesheets" rel="external">Valid <abbr title="W3C Cascading Stylesheets">css</abbr></a></p>
      <p><a href="http://modxcms.com" title="Ajax CMS and PHP Application Framework">MODx</a></p>
      </div>
      <!-- close #sidebar -->
      </div></div></div>
      </body>
      </html>


      The MemberCheck code in the first line and the WebLoginSidebar are from the default MODx template. I’ve just used some CSS to restyle the basic MODx template while I’m still learning. Are these Snippets somehow conflicting with the Personalize Snippet?
        NOTE TO SELF: http://www.muddydogpaws.com/development/wayfinder/examples/example-1.html for all your navigational questions.
        • 14412
        • 74 Posts
        I guess there’s many ways to solve this, that’s the beauty of MODx.

        Now, wouldn’t it be simpler to just create the webuser groups/docgroups as gerryn described and put the weblogin snippet on the unauthorized page (that is set on the site config page)? This way, everytime a user tries to see a restricted page, he get redirectioned to that page - no need to use chunks etc etc...

        Another option, if you want to distinguish between the Login page and a sitewide unauthorized page (e.g. if you still want some pages to be restricted to web users after logging in), a plugin like this should do the trick:
        [CODE REMOVED]<br /><br />[color=red][b]Edit:[/b][/color] the code i had posted wasn’t quite doing what I intended (plus it caused redirect errors), so I removed it.<br /><br />nate22, in the code you posted:<br />[list]<br />[li]you have the first call to MemberCheck outside the page’s <html> - is that on purpose?[/li] <br />[li]The [*#content*] is commented, so MODx won’t output any page content[/li]<br />[/list]<br /><br />Anyway, I don’t think these are related. I advise you to start over with the original template and do this:<br /><br />[b]In Security -> Web Permissions: [/b]<br />[list]<br />[li]Create a Web user group[/li]<br />[li]Create a Web Doc group and link it to the User group you created[/li]<br />[/list]<br />[b]In Security->Web Users[/b]<br />[list]<br />[li]Edit each web user and assign them the user group you created[/li]<br />[/list]<br />[b]In the site documents tree:[/b]<br />[list]<br />[li]Create 1 or 2 documents you want to restrict access to (check the Web Doc Group box on the bottom of the edit page[/li]<br />[li]Create a new document, name it "Login page" and on its content place the [!WebLogin!] snippet call.[/li]<br />[/list]<br />In [b]Tools->Configuration (Site)[/b], change the "Unauthorized page" setting to match the id of the "Login Page" you created.<br /><br />From now on, any webuser trying to access any of the 2 documents you created should be forwarded to a page with the login form<br /><br />Hope this helps,<br />JP
          Got Music? Try XSPFjukebox - Skinnable MODx Media Player
          • 20991
          • 99 Posts
          Joeindio, I’ll look into your suggestions, as they aren’t really clear to me at the moment.

          I’d like to know what the problem is with the above code I pasted just above your reply. Maybe Personalize isn’t the ideal solution to this problem, I don’t know, but I’ve gotten this far and understand it conceptually. Now, I’d just like to know why it isn’t working. Like I said, my guess is that there is some sort of conflict with the bolded snippets.

          EDIT: I see you have updated your code... thanks, I’ll check it out.
          By the way, [*#content*] is commented out because the Personalize Snippet replaces the [*#content*] and, if logged in, will use the "loggedIn" chunk, which is simply [*#content*].
            NOTE TO SELF: http://www.muddydogpaws.com/development/wayfinder/examples/example-1.html for all your navigational questions.
            • 20991
            • 99 Posts
            Yup, the web groups works fine for what I need. Thank you all very much. I’m a bit un-thrilled by the disappearing menu, but I guess it doesn’t matter. I know they wouldn’t be functional, anyway, but I like the look of the menu with a login form below, which is why I was trying to use the Personalize Snippet. I guess after I’ve spent a year playing around with chunks, I’ll go back and try Personalize again.
              NOTE TO SELF: http://www.muddydogpaws.com/development/wayfinder/examples/example-1.html for all your navigational questions.
              • 28042 ☆ A M B ☆
              • 24,524 Posts
              Keep in mind that a dynamic menu is not always completely necessary. If your top-level or even second-level container documents won’t change, a static menu will work just fine.
                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
                • 20991
                • 99 Posts
                Good point! wink

                A parting question before this thread is through...

                The Login/Logout Snippet displays the following message once a user is logged in:

                You’re already logged in
                Do you wish to Logout?

                How can I change this text? "You are currently logged in" is much preferable for the simple reason that after logging in, the Snippet gets relegated to the sidebar. Since there is no continuity, it is a bit jarring and weird as you’re reading the sidebar. And also, I would just like to know how to edit such things so that I can customize Snippets and Chunks in the future.
                  NOTE TO SELF: http://www.muddydogpaws.com/development/wayfinder/examples/example-1.html for all your navigational questions.
                  • 28042 ☆ A M B ☆
                  • 24,524 Posts
                  It’s being set in the placeholder [+logouttext+], but I don’t see where that is being set from. Check your template and your snippet call.

                  Um...which one are you using, the default WebLogin, or WebLoginPE?
                    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 use the personalize snippet to show a deeper menu to logged-in web users and just a "logged in as: username" at the top of the menu.

                    Here’s the loggedInWayfinderChunk:

                    <b>  Logged in as: [+user+]</b><hr>
                    [[Wayfinder?&startId=`0`&level=2 &titleOfLinks=`description`]]


                    The notLoggedInWayfinderChunk is the same but with &level=1.

                    I have another personalize snippet in the footer that uses a chunk to display "logged in as: user name" logout change password for logged-in users.

                    Here’s the footerLoggedInChunk:
                    Logged in as: [+user+]     <a href="[~12~]?webloginmode=lo">Log Out</a>   <a href="[~49~]">Change Password</a>
                    


                    Not-logged-in users just see this chunk in the footer:
                    notLoggedInFooterChunk:
                    <a href="[~12~]">Log in</a>
                    


                    Bob
                      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
                      • 20991
                      • 99 Posts
                      Quote from: sottwell at Oct 23, 2007, 12:01 AM

                      It’s being set in the placeholder [+logouttext+], but I don’t see where that is being set from. Check your template and your snippet call.

                      Um...which one are you using, the default WebLogin, or WebLoginPE?

                      Found it: it’s under Chunks > User Management > FormLogin - Custom login form for Weblogins
                        NOTE TO SELF: http://www.muddydogpaws.com/development/wayfinder/examples/example-1.html for all your navigational questions.