We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 27708 MODX Staff
    • 2,502 Posts
    Logout Manager Links
    A snippet based on Adam Crownoble’s LoginLogoutLink (8/3/2005) and QuickEdit.

    Purpose
    The purpose of Logout Manager Links is to allow people using front end editors such as quick edit, or FrontEndDocument Manager to logout or go to the Manager. It creates a set of links that appear where called that looks as follows: Logout | Go to Manager.

    If logged in the manager user will see the links where called. If not logged in noone else will see the links.

    Usage:

    You can change the output text via the parameters or using a template chunk.

    Simple (No Params/Default)

    [!LogoutManagerLinks!]


    With optional user template

    [!LogoutManagerLinks? &tpl=`chunkname`!]


    Where chunkname is the name of your chunk that contains a template
    with the required placeholders [+loURL+] and [+mgrURL+]

    1. Create a chunk called "lmlTml" (or whatever you want) and place your link template as below:
    <a href="[+loURL+]" title="Logout Link Title">Logout Now!</a><br/>
    		<a href="[+$mgrURL+]" title="Go to Manager Title">Go to Manager Now!</a>

    2. Place your call in your page as below:
    [!LogoutManagerLinks? &tpl=`lmlTpl`!] 
    (or using whatever you named the chunk)

    Important!: Do not place the chunk call in the document as it will be visible to all users.

    Parameters
    &lo_link_name - Link text to appear on page. (String)[Optional] Default: Logout
    &lo_link_title - Link title for the link to appear in <a> element as title value.(String)[Optional] Default: Click here to logout.
    &lo_doc_id - Document to send user to on logout.(String)[Optional] Default: current document.
    &mgr_link_name - Link text to appear on page.(String)[Optional] Default: Go to Manager.
    &mgr_link_title - Link title for the link to appear in <a> element as title value.(String)[Optional] Default: Click here to go to manager.
    &tpl - Name of chunk to use for ouput. (String)[Optional] //Added V. 0.2

    Current Version: 0.2

    Changes:
    Version 0.2: 06-01-2008 - Add ability to use optional user template from chunk.
    Version 0.1: 19-12-2007 - Initial release.

    Todo:
    Make it possible to use chunk id, @code:, and @file: for template.


      Author of zero books. Formerly of many strange things. Pairs well with meats. Conversations are magical experiences. He's dangerous around code but a markup magician. Blog ✦ Twitter ✦ LinkedIn ✦ GitHub
      • 7231
      • 4,205 Posts
      This is nice, I was just wishing that this existed (it is a x-mass miracle). I will be using it on a current project for sure. Very handy to have. Thanks. grin
        [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

        Something is happening here, but you don&#39;t know what it is.
        Do you, Mr. Jones? - [bob dylan]
        • 27708 MODX Staff
        • 2,502 Posts
        dev_cw,

        Thanks. Let me know if there are any issues. It is my first real snippet (I have done a few real simple PHP functions before but not with parameters and that interacted with the API).

        Let me know also if you need more documentation or examples. I am torn about extending that area as it is such as simple snippet.

        Cheers,

        Jay
          Author of zero books. Formerly of many strange things. Pairs well with meats. Conversations are magical experiences. He's dangerous around code but a markup magician. Blog ✦ Twitter ✦ LinkedIn ✦ GitHub
          • 6726
          • 7,075 Posts
          Nice !
          I’ll soon have a use for it also and will be testing this next week smiley
            .: COO - Commerce Guys - Community Driven Innovation :.


            MODx est l&#39;outil id
            • 27708 MODX Staff
            • 2,502 Posts
            davidm,

            Hope this helps. It was pretty exciting for me as I am still doing PHP with training wheels on.

            ATB,
            Jay
              Author of zero books. Formerly of many strange things. Pairs well with meats. Conversations are magical experiences. He's dangerous around code but a markup magician. Blog ✦ Twitter ✦ LinkedIn ✦ GitHub
              • 38290
              • 712 Posts
              Anybody know how to do this same thing in Revo?
                jpdevries
                • 28042 ☆ A M B ☆
                • 24,524 Posts
                Revo doesn't have two types of users, all users are just "users" with different permissions associated with the groups they belong to. Manager users must belong to a group with mgr access.

                To give a manager user different links than a visitor user, check if he belongs to your mgr group:
                $user->isMember('UserGroupName')
                  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
                  • 28042 ☆ A M B ☆
                  • 24,524 Posts
                  You can also check for his session context using getSessionContexts()
                  if(in_array('mgr', $user->getSessionContexts())) ...;
                  


                  http://rtfm.modx.com/display/revolution20/modUser
                    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
                    • 38290
                    • 712 Posts
                    Right but, I'm not sure what that has to do with whether or not you can log a user out by sending them to a URL like /manager/?action=loggout
                      jpdevries
                      • 28042 ☆ A M B ☆
                      • 24,524 Posts
                      Ah. You got me there. User management and contexts is still not quite clear for me.
                        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