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

    I manage a site with MODx as CMS, and others (not really known to computers and such, I’m just glad they know *a bit* how to work MODx wink) are maintaining the content. That’s the only right they have received.
    They keep forgetting to uncheck the "Visible in menu" item causing the menu to look not the way its intended.

    I’ve looked for a setting to uncheck this box per default, but there is none. I’ve looked in the source if I saw a way to disable it on default but no luck there either.

    The only occurence of "hidemenucheck" I’ve found is in "manager\actions\mutate_content.dynamic.php"
    I’ve tried to change the conditions, but it didn’t behave as I hoped.

    So: How can I disable the auto-ticking of the checkbox "Visible in menu".

    Thanks.
      • 7231
      • 4,205 Posts
      You can use a plug-in, or if you are using the Inherit Parent Template plug-in you can simply edit it and add the command to de-select the checkbox.

      Add $content[’hidemenu’] = "1"; before the first break.

      The edited plugin would look like this:
      /*
       * Inherit Template from Parent
       * Written By Raymond Irving - 12 Oct 2006
       *
       * Simply results in new documents inherriting the template 
       * of their parent folder upon creating a new document
       *
       * Configuration:
       * check the OnDocFormPrerender event
       *
       * Version 1.0
       *
       */
      
      global $content;
      $e = &$modx->Event;
      
      switch($e->name) {
        case 'OnDocFormPrerender':
          if(($_REQUEST['pid'] > 0) && ($id == 0)) {
            if($parent = $modx->getPageInfo($_REQUEST['pid'],0,'template')) {
              $content['template'] = $parent['template'];
            }
          }
          $content['hidemenu'] = "1";
          break;
      
        default:
          return;
          break;
      }
      
        [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't know what it is.
        Do you, Mr. Jones? - [bob dylan]
        • 29107
        • 9 Posts
        Thanks for the help.
        The only problem is that it doesn’t work as I hoped.

        The current structure is:
        CAT_1 (visible) -> CAT_2 (visible) -> DOC_1 (invisible).

        When I edit a random entry, that is visible. Its unchecked.

        The category ID’s -that shouldn’t contain "menu visible" elements- are: 56, 46, 4, 5, 6, 11, 12.
        If there’s a way to check what parent there is, I think that will supply me with what I need smiley

        I was thinking somewhat like this (that doesn’t work obviously)
        global $content;
        $e = &$modx->Event;
        
        switch($e->name) {
          case 'OnDocFormPrerender':
             switch($parent)
             {
                 case 56, 46, 4, 5, 6, 11, 12:
                 $content['hidemenu'] = "1";
                 break;
             }
            break;
        
          default:
            return;
            break;
        }
          • 7231
          • 4,205 Posts
          Good point. Here try this out. Replace the inherit parent template plugin with this one. I added an array where you can set the containers to turn the menu off in. Then it checks to see if the parent id is in the array and turns the show in menu btn off.

          global $content;
          $e = &$modx->Event;
          $containers = array(99,102,104,127); 
          
          switch($e->name) {
            case 'OnDocFormPrerender':
              if(($_REQUEST['pid'] > 0) && ($id == 0)) {
                if($parent = $modx->getPageInfo($_REQUEST['pid'],0,'template')) {
                  $content['template'] = $parent['template'];
                }
                if(in_array($_REQUEST['pid'], $containers)) { 
              		$content['hidemenu'] = "1";
                }
              }
              break;
          
            default:
              return;
              break;
          }
            [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't know what it is.
            Do you, Mr. Jones? - [bob dylan]
            • 29107
            • 9 Posts
            Perfect. Seems like this is what I need smiley Thanks!
              • 7231
              • 4,205 Posts
              I just thought of another option. You can set it so that new documents are set to not show in menu but when editing it does not make a change to the existing value. Just add this to the switch case in place of the previous code:
              	if($_REQUEST['a'] == "4") {
                  		$content['hidemenu'] = "1";
              	}


              There are so many solutions in MODx. 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't know what it is.
                Do you, Mr. Jones? - [bob dylan]
                • 8894
                • 114 Posts
                I find you could post it into repository because it can be very useful laugh