We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 36446
    • 184 Posts
    Hi!
    I want to do the following: I have a page where registered and logged in users can download stuff. This page should not be shown in the menu when not logged in.
    I used the http://modxcms.com/forums/index.php/topic,25992.0.html (dtree menu) for my sitenavigation. Has anybody done something like that and give me a hint on how to do it?
    Thank you very much!
      https://www.beautyislife-shop.de - premium make-up!
      https://www.topsterne.de - sell it here!
      ---------------------------------------------------------
    • Apparently the dtree menu doesn’t check for permissions. The best I can suggest is to use a snippet to check if the user is logged in, and redirect him back to another page if he isn’t.

      There’s also this http://www.modxcms.com/CheckLogin-1503.html
        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
        • 36446
        • 184 Posts
        hmmm.. that is happening automatically when a user logs in.... but how can i use this snippet for the menu? i tried (quick and dirty and not working) to put the snippet call in the Menutitel - i thought that this might work, but it isnt working....
          https://www.beautyislife-shop.de - premium make-up!
          https://www.topsterne.de - sell it here!
          ---------------------------------------------------------
          • 4310
          • 2,310 Posts
          @zven69
          Try this snippet code instead of the original.
          It now evaluates if the user is logged in and displays private web pages in the menu.
          If they are not logged in they don’t show in the menu.
          Tested quickly by me.
          <?php
          $siteName = $modx->config['site_name'];
          $output = '';
          $output .= '<script type="text/javascript">
          <!--
          d = new dTree(\'d\');
          d.add(0,-1,\'Sandbox Menu\');';
          if ($modx->getLoginUserID())
          {
          $result = mysql_query('SELECT * FROM `modx_site_content` WHERE `published`= 1 AND `hidemenu`= 0 AND `deleted`= 0 ORDER BY `menuindex` ASC ');
          while($row = mysql_fetch_array($result))
          {
          $output .= 'd.add( '. $row['id'] . ' , '. $row['parent'] . ' , \''. $row['pagetitle'] . '\', \'[~'. $row['id'] . '~]\');'."\n";
          }
          }
          else
          $result = mysql_query('SELECT * FROM `modx_site_content` WHERE `published`= 1 AND `hidemenu`= 0 AND `deleted`= 0 AND `privateweb`= 0 ORDER BY `menuindex` ASC ');
          while($row = mysql_fetch_array($result))
          {
          $output .= 'd.add( '. $row['id'] . ' , '. $row['parent'] . ' , \''. $row['pagetitle'] . '\', \'[~'. $row['id'] . '~]\');'."\n";
          }
          $output .= '
          document.write(d);
          //-->
          </script>';
          return $output;
          ?>
          
            • 3749
            • 24,544 Posts
            I use the Personalize snippet, which shows one chunk to logged-in users and another chunk to everyone else. I put the full menu (actually a Wayfinder call) in one chunk and the partial menu in the other.
              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
              • 36446
              • 184 Posts
              @bunk58
              Yeah! Nice! it works! Thank you very much!
              grin
              Peace!
                https://www.beautyislife-shop.de - premium make-up!
                https://www.topsterne.de - sell it here!
                ---------------------------------------------------------
                • 4310
                • 2,310 Posts
                Glad it’s working for you!