We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 36926
    • 701 Posts
    Hi,

    Wonder if anyone could help with using custom templates.

    I want to have a login option within the header which displays the username if already logged in

    so if your not logged in you would have in the header

    login | Register

    and if you are logged in you would get

    Welcome back bennyb | logout

    Thanks in advance!!!

    Ben

      • 36926
      • 701 Posts
      Hi,

      I wanna have a go at this myself but not really sure where to start. Do i need to create snippet that will look at if the user is logged in or not and show different chunks depending if they are logged in or not.

      Thanks
      Ben
        • 26435
        • 1,193 Posts
        Hi Ben.

        Just put the WebLoginPE call in your template where you want the output to appear. The call would look something like this.
        [!WebLoginPE? &regHomeId=`25` &profileHomeId=`26` &loginFormTpl=`benLogin` &successTpl=`benWelcome`!] 

        where `25` would be the MODx document id for the page with the WebLoginPE login form and `26` would be the MODx document id for the page with the WebLoginPE profile form.

        then make two chunks. One called "benLogin" and the other called "benWelcome".

        benLogin Chunk:
        <a href="[~27~]" title="Login">Login</a> | <a href="[~25~]" title="Register for a new account">Register</a>

        27 would be the MODx document ID of a page with a standard [!WebLoginPE!] call in the content area.

        benWelcome Chunk:
        Welcome Back [+user.username+]! | <a href="[~[*id*]~]?service=logout" title="Logout">Logout</a>


        -sD-
        Dr. Scotty Delicious, DFPA.
          Husband, Father, Brother, Son, Programmer, Atheist, Nurse, Friend, Lover, Fighter.
          All of the above... in no specific order.


          I send pointless little messages
          • 36926
          • 701 Posts
          Thanks Scotty for the reply and a great snippet,

          Got it sort of working, but a couple of things when registering a user.

          First if i click Register i’m taken to the register page which has the &type=`verify` i fill in the details and click register. I’m then taken to the login page which has overlapping it a register form which is coming from the weblogin call in the header. I’ve attached a screen shot. And at the bottom of this post are the calls i’m using.

          Can i also just check a couple of things with your instructions, you said:
          1)
          &regHomeId=`25`
          where `25` being the WebLoginPE login form
          How comes regHomeId doesn’t link to a registration page?

          2)
          For the benWeclcome chunck do i need to specify an id page for the logout option as its only got [~[*id*]~]

          Welcome Back [+user.username+]! | <a href="[~[*id*]~]?service=logout" title="Logout">Logout</a>

          These are the calls i’m using

          Reg page:
          [!WebLoginPE? &type=`register` &regType=`verify` &registerTpl=`register` &regRequired=`email,username,fullname` &customFields=`company` &groups=`registeredusers` !]

          login:
          [!WebLoginPE? !]

          profile:
          [!WebLoginPE? &successTpl=`welcomeuser` !]

          Thanks again for the response.

          Ben
            • 28033
            • 925 Posts
            Sounds to me like it’s a CSS issue, rather than something in WLPE. Can’t tell without a link to the code, though.
              My Snippets
              -> PopUpChunk v1.0
              • 36926
              • 701 Posts
              Hi,

              Thanks for the reply. I’m pretty sure it’s not a CSS problem, as the login and register works fine when a webloginpe call isn’t within header.
              Also I placed the header weblogin call in the template without any styles as just trying to get the functionality working first. And as you can see from the image I attached the registration form is being generated from the call that is within the header but i don’t need this call to generated the registration call as this is already being generated in the main body. What i have done to get around this is within the header weblogin call i’ve specified a blank chunk for &registerTpl and this sort of works but now the header doesn’t display anything.

              Thanks

              Ben
                • 9934
                • 3 Posts
                Quote from: Dr. at Dec 01, 2007, 12:20 PM

                benWelcome Chunk:
                Welcome Back [+user.username+]! | <a href="[~[*id*]~]?service=logout" title="Logout">Logout</a>


                Hi,

                First of all a big thanks for a great snippet!

                I have been mad with this service=logout for some time tonight.
                The thing is that I didn’t really checked what I cut’n pasted.
                Welcome Back [+user.username+]! | <a href="[~[*id*]~]&service=logout" title="Logout">Logout</a>

                There should be a &service=logout instead of ?service=logout.

                My mistake not checking the code, but when trying out something as a noob like me stuff like that can bring you down smiley

                And I get the same problem as bennyb.

                Quote from: bennyb at Dec 02, 2007, 06:24 PM

                Thanks for the reply. I’m pretty sure it’s not a CSS problem, as the login and register works fine when a webloginpe call isn’t within header.
                Also I placed the header weblogin call in the template without any styles as just trying to get the functionality working first. And as you can see from the image I attached the registration form is being generated from the call that is within the header but i don’t need this call to generated the registration call as this is already being generated in the main body. What i have done to get around this is within the header weblogin call i’ve specified a blank chunk for &registerTpl and this sort of works but now the header doesn’t display anything.


                It’s the main
                [!WebLoginPE? &regHomeId=`13` &profileHomeId=`15` &loginFormTpl=`wlpeLogin` &successTpl=`wlpeWelcome` !]

                That shows the register page when you pressed Register on the register page (id=13).

                Did you solve that?

                Again, thanks for the great snippet!

                --
                Regards Folke
                Sweden
                  • 28042 ☆ A M B ☆
                  • 24,524 Posts
                  if you are using Friendly URLs it needs to be ? and if you are not using Friendly URLs it needs to be &. Consider your URL:

                  If you are using friendly URLs you’ll have
                  http://www.domain.com/alias.html?key=value
                  If you are not using friendly URLs you’ll have
                  http://www.domain.com/index.php?id=xx&key=value
                    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
                    • 9934
                    • 3 Posts
                    Quote from: sottwell at Dec 25, 2007, 11:35 PM

                    if you are using Friendly URLs it needs to be ? and if you are not using Friendly URLs it needs to be &. Consider your URL:

                    Ah, you see.

                    I’m new to modx, I am an "old" typo3 user.

                    Thanks, I will RTFM some more before I put out faulty posts in the forum..

                    Do you have any ideas how to make the main script not to show the register page too when registering?

                    --
                    Regards Falk