We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 28042 ☆ A M B ☆
    • 24,524 Posts
    I am SO proud of myself! grin I actually did something useful today!



    Add this to the l4mnu.php frame:

    <!-- Modules -->
    <?php  if($modx->hasPermission('exec_module')) { ?>
        <li id="limenu9"><a href="#menu9" onclick="new NavToggle(this); return false;"><?php echo $_lang["modules"]; ?></a>
            <ul class="subnav" id="menu9">
    <?php
      $list = '';  // initialize list variable 
      $rs = $modx->db->select('*',$modx->getFullTableName('site_modules'));  // get modules
      while($content = $modx->db->getRow($rs)) {
        $list .= '<li><a onclick="this.blur();" href="index.php?a=112&id='.$content['id'].'" target="main">'.$content['name'].'</a></li>';
    	}
    	echo $list;
    ?>
            </ul>
        </li>
    <?php } ?>
    


    There still needs to be a way to indicate disabled modules, but that will require a modification to the module processing snippet to refresh the menu if a module is disabled/enabled.

    Also should check for user access permission to each module before creating the link, but that’s all just extras.
      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
      • 25663 MODX Staff
      • 12,272 Posts
      Wow Susan... very nice indeed. laugh

      Wanna head up the effort for making sure this doesn’t slip under the radar for 0.9.2?
        Ryan Thrash, MODX Co-Founder
        Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
        • 28042 ☆ A M B ☆
        • 24,524 Posts
        It still needs those two added features, the checking for user groups permissions I think I can do, but I don’t know how to force the menu frame to be refreshed on saving a module.

        In the meantime what do I do with it? Put it in the bugtracker?
          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
          Ok, I think I got the permissions bit fixed. I would be happy if it could get beat on by other people, though.

          Here’s the full version of the menu addition:

          <!-- Modules -->
          <?php  if($modx->hasPermission('exec_module')) { ?>
              <li id="limenu9"><a href="#menu9" onclick="new NavToggle(this); return false;"><?php echo $_lang["modules"]; ?></a>
                  <ul class="subnav" id="menu9">
          <?php
            $list = '';  // initialize list variable 
            $rs = $modx->db->select('*',$modx->getFullTableName('site_modules'));  // get modules
            while($content = $modx->db->getRow($rs)) {
            // check if user has rights to this module
              $has_permission = '1'; // presume permission
              if($_SESSION['mgrRole']!=1){  // full admin users always have permission
                 $sql = "SELECT sma.usergroup,mg.member " .
                "FROM ".$modx->getFullTableName("site_module_access")." sma " .
                "LEFT JOIN ".$modx->getFullTableName("member_groups")." mg ON mg.user_group = sma.usergroup AND member='".$modx->getLoginUserID()."'".
                "WHERE sma.module = '$id' LIMIT 1";
                $rs = $modx->dbQuery($sql);
                $row = $modx->fetchRow($rs);
                if($row["usergroup"] && !$row["member"]) { 
                  $has_permission = '0';
                }
              }
              if($has_permission == '1'){    
                $list .= '<li><a onclick="this.blur();" href="index.php?a=112&id='.$content['id'].'" target="main">'.$content['name'].'</a></li>';
              }
          	}
          	echo $list;
          ?>
                  </ul>
              </li>
          <?php } ?>
          
          
            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
            • 18397
            • 3,250 Posts
            Great work! But what what happened to the manage modules link?
              • 28042 ☆ A M B ☆
              • 24,524 Posts
              Nothing at all. It’s still where it always was, under Resources. This is a top-level menu item intended for end users running a module to manage something like the EPGallery. Now they don’t need to go to Resources, Modules, right-click on the little icon and Run Module.
                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
                • 18397
                • 3,250 Posts
                Silly me! Anyways, if this makes it into the core for 0.9.2 (which I think it should) should clicking on a module name when managing modules edit the module again? (I changed it in the SVN to run the module)
                  • 25663 MODX Staff
                  • 12,272 Posts
                  Nicely done Susan and thanks. I moved the manage modules from the Resources tab and committed this for 0.9.2 as rev 724.
                    Ryan Thrash, MODX Co-Founder
                    Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
                    • 33337
                    • 3,975 Posts
                    Grrreat Worrrk! laugh
                      Zaigham R - MODX Professional | Skype | Email | Twitter

                      Digging the interwebs for #MODX gems and bringing it to you. modx.link
                      • 28042 ☆ A M B ☆
                      • 24,524 Posts
                      All this menu does is RUN the modules! You still need the manage modules item for editing the module! This menu item is intended for our clients, the end users, who will be using the module to manage whatever (such as the EPG module). The developers will still need the manage modules access for working with the module’s code. I specifically did it this way (not moving the entire module management system) to avoid confusing our client end-users.
                        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