We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 13736
    • 345 Posts
    I am wanting to set up a site with some dynamic login information in the header. So far I haven’t been able to get the WebLoginBox to display correctly maybe I’m not doing something right or maybe what I want to do isn’t possible yet. I haven’t found any tutorial in the forum on this yet, so could I get some help on how to make this work? If it’s possible.

    For NON-logged in viewers I want the header to display register and login links like...


    For those who are logged in I want the header to display their name and a logout link.


    How would I go about getting this info to change based on whether the user is logged in or not?

      • 33337
      • 3,975 Posts
      Look for "Personalize - NEW! Basic personalization for web users." snippet in your MODx install.

      Hope it helps.

      regards,

      zi
        Zaigham R - MODX Professional | Skype | Email | Twitter

        Digging the interwebs for #MODX gems and bringing it to you. modx.link
        • 13736
        • 345 Posts
        It helps slightly. The Personalize snippet looks like it will create a static message with the users name tacked on the end. But how would one determine whether to display a "register" link if the user wasn’t logged in, or the Personalize snippet once the login was made?

        And then switching the Login to Logout depending on the same situation?

          • 28042 ☆ A M B ☆
          • 24,524 Posts
          Put the placeholder from the Personalize snippet in the template for the login form, as part of the logout section.
            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
            • 13736
            • 345 Posts
            Maybe I’m not grasping the whole picture. I don’t know.

            But from what I’ve read on the Weblogin snippet, I don’t see how I can get what is pictured in the initial images I put in the first post. And how does it become dynamic based on whether the user is logged in or out?

            The actual page I’m linking to is ID=19 or http://modx.acgi.org/login
            and for registration ID=20 or http://modx.acgi.org/register

            Also what place holder from the Personalize snippet were you talking about. The documentation in the header of the snippet doesn’t mention any built in place holders.



              • 28042 ☆ A M B ☆
              • 24,524 Posts
              #  &ph [boolean] ( optional ) 
              #		if set, outputs to the ph name passed in, instead 
              #		of directly returning the output
              


              That’s not really explained clearly, it does not take a true/false value, but the name you wish to use for the placeholder.

              [!Personalize? &ph=`user` !]
              


              although the code itself does use a boolean test to determine whether to set a placeholder or simply output the results.

              The above would produce a placeholder to be used like this:

              [+user+]
                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
                • 13736
                • 345 Posts
                Ah. cool. Sombody been using shorthand in the descriptions. I had wondered what that ph meant. Place Holder never occured to me.

                One more thing I meant to ask in the last post for whoever might know.

                In the Weblogin snippet header it talkes about Templates with sections 1, 2, and 3. And says reference weblogin.tpl for more information. Where is that weblogin.tpl. It’s definitely not in the snippet text anywhere that I can see and the search in these forums doesn’t bring back much of any results.
                  • 28042 ☆ A M B ☆
                  • 24,524 Posts
                  It’s in your assets/snippets/weblogin folder.

                  The default template is actually part of weblogin.inc.php in the same folder.
                    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
                    • 13736
                    • 345 Posts
                    Has anyone actually done this before? Or are these suggestions just theoretical. Because it’s not working for me.

                      • 28042 ☆ A M B ☆
                      • 24,524 Posts
                      I have it on my site.
                        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