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

    I have got the WebLoginPE working great, and my only problem is that I want to display a link to the member page in the page header if a person is logged in and hide the login link.

    These links are in the header area of the template and coded as follows:
          <li><a href="#">Home</a></li>
          <li><a href="[~4~]">Login</a></li>
          <li><a href="#">Privacy Policy</a></li> 
          <li class="last">[!AjaxSearch? &ajaxSearch=`0`&AS_showResults=`0`&AS_landing=`5`!]</li>


    So is it possible to have it display the following if the user is logged in
     <li><a href="#">Home</a></li>
         <li><a href="index.php?id=48">Members Area</a></li>
          <li><a href="#">Privacy Policy</a></li> 
          <li class="last">[!AjaxSearch? &ajaxSearch=`0`&AS_showResults=`0`&AS_landing=`5`!]</li>


    Thanks for any help in advance.
      • 4041
      • 788 Posts
      Make the following code into a snippet and replace the menu in the template with the snippet call uncached:

      [!LoginLinkMenu!] or whatever you want to name it smiley

      <?php
      /* Login Link snippet */
      // if user is logged in
      $logged_in_ID ='48';
      $logged_in_text ='Members Area';
      
      // otherwise general public
      $login_page_ID ='4';
      $login_text ='Login';
      
      $output ='';
      
      if(isset($_SESSION['webShortname'])){
        $loginlink = $logged_in_ID;
        $logintext = $logged_in_text;
      }else{
        $loginlink = $login_page_ID;
        $logintext = $login_text;
      }
      
      $output .='
      <li><a href="#">Home</a></li>
      <li><a href="[~'.$loginlink.'~]">'.$logintext.'</a></li>
      <li><a href="#">Privacy Policy</a></li>
      <li class="last">[!AjaxSearch? &ajaxSearch=`0`&AS_showResults=`0`&AS_landing=`5`!]</li>';
      
      return $output;
      ?>

      you may have to fiddle around with this because of the ajaxsearch but this is the basic way to achieve what you want.
        xforum
        http://frsbuilders.net (under construction) forum for evolution
        • 3749
        • 24,544 Posts
        All you have to do is put your two examples in separate chunks called:

        LoggedOnChunk and NotLoggedOnChunk.

        Then, where you want the output, put a call to the Personalize snippet with the names of those two chunks as parameters.

        [!Personalize? &yesChunk=`LoggedInChunk` &noChunk=`NotLoggedInChunk` &ph=`user`!]


        Logged in users will see one, not-logged-in users will see the other. There’s even a placeholder so you can say "Hello [+user+]" to a logged-in user.

          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
          • 22840
          • 1,572 Posts
          Thanks,

          I used the 2nd suggestion because it was simpler as the client may need to alter the nav in the future, so the simpler the better.

          The only issue was the ajax search broke so I just put that in back into the template file under the call and all is well grin