We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 20991
    • 99 Posts
    I am guessing there is a simple way to password protect a page based on the LOGIN function... It’s probably as simple as checking a little box or something, similar to the checkbox option to list a page in the navigation menu, but I can’t seem to figure it out.
      NOTE TO SELF: http://www.muddydogpaws.com/development/wayfinder/examples/example-1.html for all your navigational questions.
      • 22303 MODX Staff
      • 10,725 Posts
        • 3749
        • 24,544 Posts
        Quote from: OpenGeek at Oct 16, 2007, 04:31 PM

        Start with...

        http://www.modxcms.com/web-users-web-groups.html

        It might also work to put the [[personalize]] snippet in the template of every page except the index page and have it re-direct non-logged-in users to the index page. If that worked, you wouldn’t have to be so careful about assigning newly created pages to document groups.

        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
          No, wait, this seems like all I need:
          MemberCheck - 1.0 Selectively show chunks based on logged in Web User’ group memberships.

          The usage example is:
          [[MemberCheck? &groups=`siteadmin, registered users` &chunk=`privateSiteNav` &ph=`MemberMenu` &debug=`true`]]

          So, it could be as simple as one line inserted into my template, right? Unfortunately, it’s based on a chunk called &chunk=`privateSiteNav` which I know I can change to whatever I want, but I have no idea how to implement it.

          Pasting the example usage directly into my template didn’t work, but that’s probably because I have no chunk called privateSiteNav, eh? I would create such a chunk if I had any clue how to go about it.
            NOTE TO SELF: http://www.muddydogpaws.com/development/wayfinder/examples/example-1.html for all your navigational questions.
            • 3749
            • 24,544 Posts
            Quote from: nate22 at Oct 17, 2007, 02:42 PM

            No, wait, this seems like all I need:
            MemberCheck - 1.0 Selectively show chunks based on logged in Web User’ group memberships.

            I’m not sure that will do what you want. Non-logged-in users would be able to navigate to all the pages but the pages would be blank (or would show different content that you would have to create). If you want to simply keep those users from ever visiting pages other than the index page, you need to look at the solutions above.

            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
              Thanks. Unfortunately, there’s not enough detail in the Personalize 2.0 instructions for it to make any sense to me, such as:

              Copy the contents of the attached file to a new snippet named "Personalize".

              Params:

              &yesChunk : name of the chunk visible to LOGGED users [REQUIRED]
              &noChunk : name of the chunk visible to UNLOGGED users [REQUIRED]
              &ph : set a placeholder to display the username in the yesChunk [optional]


              What?

              ... and the Web Users FAQ features an outdated Administration panel which looks nothing like MODx 0.9.6. so everything is in the wrong place or named differently.
                NOTE TO SELF: http://www.muddydogpaws.com/development/wayfinder/examples/example-1.html for all your navigational questions.
                • 10487 MODX Staff
                • 1,535 Posts
                Garry Nutting Reply #7, 19 years ago
                Okay, some instructions to get you going - I’ve literally just tapped these instructions out but I’ve tried both possible options on the default content and they work okay wink You basically have two options and I’ve explained below what you need to do for each of them. I’ll leave it up to you which one you choose to roll with.

                Note: The downside to the Personalize route is that because of the way it will be setup (having nested snippet calls), you will need have all your pages as uncached. Otherwise, the parser won’t render the WebLogin snippet correctly.


                Route 1: Using Web Users and Document Groups


                Setting up the User Group and Document Group

                1. Go to Security->Web Permissions from the top menu when logged into the MODx Manager.
                2. On the page that loads, under the ’Create a new user group’, add a new user group with a name of your choice.
                3. Now select the ’Document Group’ tab.
                3. Under the ’Create a new document group’, add a document group with a name of your choice.
                4. Now we need to link the user group to the document group so select the ’User/Document group links’ tab.
                5. You should the Web User Group listed that you added in step 2 above.
                6. From the dropdown in the Document Group column, select the Document Group you added in step 3. Click ’Add’.

                To restrict page access to only people who are assigned to the user group you have just added - all you have to do is select the Document Group from the list of groups under the ’Access Permissions’ heading when creating or editing a document. (The Access Permissions are at the bottom of the document editing screen, under where you edit the document content).

                To add a web user to the user group, log into the Manager and go to Security->Web Users. Select the user in question and on the edit screen you can scroll to the bottom of the page and select the user group from the ’Web Access Permissions’ section.

                Route 2: Using Personalize


                Setting up the Personalize snippet and the required chunks

                1. In the MODx Manager, go to Manage Resources and select the Snippets tab. Do you see Personalize listed? (this depends if you installed the default content or not). If you don’t, click the ’New Snippet’ link and paste the contents of the Personalize file you have into the Snippet Code textarea. Call it ’Personalize’ and hit the save button.
                2. Now select the ’Chunks’ tab from the Manage Resources page.
                3. Click the ’New Chunk’ button and on the chunk editing screen give it name of ’loggedIn’. In the chunk content, type the following (we’ll keep the content really simple at the moment):
                [*content*]

                4. Save this chunk.
                5. Create another chunk, this time calling it ’notLoggedIn’ and for the chunk content use the following (if you are using WebLogin with a different form template, then adjust the following snippet call accordingly - if you don’t have the WebLogin snippet at all then you’re best retrieving it from a MODx install that has the default content):
                [!WebLogin? &tpl=`FormLogin` &loginhomeid=`[(site_start)]`!]

                6. Save the chunk.

                Adding the Personalize Snippet to the Template

                1. Go to the template editing screen in the Manager for your chosen template.
                2. Add the following code where you would normally place the main page content:
                [[Personalize? &yesChunk=`loggedIn` &noChunk=`notLoggedIn`]]

                3. Save the template.

                Now, as long as you use that template for your pages (you can obviously add the snippet call to any other templates you may have) - if the user is logged in, they will see the main document content. If the user is not logged in, they will see the login form.

                Tweak to your heart’s content smiley

                Hope that helps,
                Garry
                  Garry Nutting
                  Senior Developer
                  MODX, LLC

                  Email: [email protected]
                  Twitter: @garryn
                  Web: modx.com
                  • 3749
                  • 24,544 Posts
                  Garyn’s instructions are right on the money and very well explained. The only change I would suggest is naming the two chunks loggedInChunk and notloggedInChunk to remind you down the road that these are chunks.

                  Also, remember that chunknames and snippet names are case-sensitive to be careful when entering them or nothing will happen and remember to put backticks rather than apostrophes in the snippet call. I don’t know if it’s still an issue but it used to be important not to have spaces on either side of the equals signs in the snippet call.


                  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
                    Garry, thank you so much! I am positive I would have never figured that out. The linking of the new group to a new document group is particularly odd, so it’s no exaggeration to say that I literally would have never figured it out on my own.

                    Another thing I noticed: the "creation" of a new Snippet is so simple (copy + paste) that it is actually confusing! The whole Snippet concept completely eluded me until I read your explanation. Thankfully, all the Snippets I needed were included in the install.

                    (On a related note, I installed the FCKeditor as the tutorial instructed, but it’s not being recognized by the MODx manager. Did I miss some simple dropdown linkage step similar to the new group->document group linkage?)

                    I really appreciate the effort you took in providing me with a foolproof explanation!

                    Bob, thanks for your additional tips. Good thoughts, very helpful!

                    I will print this page out for future reference... I think it should be added to the Wiki!

                    smiley
                      NOTE TO SELF: http://www.muddydogpaws.com/development/wayfinder/examples/example-1.html for all your navigational questions.
                      • 20991
                      • 99 Posts
                      Heh, I spoke too soon.
                      Option 1 removes the navigation (since they’re protected, it appears they just disappear from the menu, too?)
                      Option 2. just didn’t work. I added the snippet to my template, but nothing happened.
                        NOTE TO SELF: http://www.muddydogpaws.com/development/wayfinder/examples/example-1.html for all your navigational questions.