We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 436 ☆ A M B ☆
    • 265 Posts
    It seems by default all articles/blog posts created with the Articles component are hidden from menus (not the parent container but the all the children).

    Without manually going into the database and changing the "hidemenu" value from 1 to 0 is there a way to set the posts created to always show in menus? There doesn't seem to be a system setting to switch this off?

    I realise the reason its been created this way is so a site with many blog posts don't overload a drop-down menu or something, but I have a scenario where I need the articles to be shown in menus.

    For this example, using &showHidden=`1` would not work because I don't want other hidden pages to be displayed.
      MODX Ambassador for Thailand. Managing Director at Monogon, a web design and development studio based in Bangkok, Thailand. - Follow me on Twitter.
      • 3749
      • 24,544 Posts
      Adam, I don't think hidemenu is involved. AFAIK, it's the show_in_tree field.

      I think a plugin connected to OnDocFormSave with this code might do it (assuming that OnDocFormSave gets invoked when saving an Article):


      $resource->set('show_in_tree', true);
      $resource->save();
      

        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
        • 436 ☆ A M B ☆
        • 265 Posts
        Actually for this I was referring to the front-end usage, not the back-end tree.

        For all of the resources created by Articles, by default, hidemenu is set to 0. Articles hides the hidemenu checkbox, so I thought if I could get the checkbox back and tick it then the items would show in the front-end menus.

        In the end I did a bit of a hack, I went into two files, the first was /assets/components/articles/js/article/create.js on line 266 and the second was /assets/components/articles/js/article/update.js on line 454 and added this:
        {
                       xtype: 'xcheckbox' 
                        ,name: 'hidemenu'
                        ,fieldLabel:_('resource_hide_from_menus')
                        ,value: 0
                        ,checked:false                
                        ,id: 'modx-resource-hidemenu'
                        ,value: config.record.hidemenu
        
                    }

        Then the Hide in Menu checkbox appears on the resource, which I can then tick to make the items appear in the front-end menus. Its very hacky, and next time I update the Articles component I'll loose my changes, but it works for now.
          MODX Ambassador for Thailand. Managing Director at Monogon, a web design and development studio based in Bangkok, Thailand. - Follow me on Twitter.
          • 3749
          • 24,544 Posts
          Sorry I misunderstood your post.

          I think another way to go, if you want all of them to show, is a plugin connected to OnBeforeDocFormSave with this code:

          if ($resource->get('class_key') == 'Article') {
              $resource->set('hidemenu', '0');
          }



          If that doesn't work, doing this in a plugin connected to OnDocFormSave almost certainly would:


          if ($resource->get('class_key') == 'Article') {
              $resource->set('hidemenu', '0');
              $resource->save();
          }


          Obviously, your solution is better if you want to be able to control it from the Create/Edit Resource panel.

          I'm sure there's a way to add the field in a plugin but this really should be a standard feature of Articles.
            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
            • 436 ☆ A M B ☆
            • 265 Posts
            I agree it should be standard, or at least a way to use the core Form Customiser to manipulate the Articles resources.

            Your solution is more elegant because it doesn't require hacking the Articles core code.

            If you think of a way to use a Plugin to add the field, rather than hacking the core, please let me know smiley
              MODX Ambassador for Thailand. Managing Director at Monogon, a web design and development studio based in Bangkok, Thailand. - Follow me on Twitter.
              • 3749
              • 24,544 Posts
              If you have a copy of my book, there's an example on pages 492 and 493 the does the same thing with the User form. It displays the extra field in a plugin when OnUserFormRender fires and saves it in the same plugin when OnUserFormSave fires. With minor modifications I think it would work with resources and OnDocFormRender and OnDocFormSave, but I've never tried it.

              Actually, you could create a hidemenu checkbox TV called HideMenu and use something like this in OnDocFormSave:


              if ($resource->get('class_key') !== 'Article') {
                   return '';
              }
              $resource->set('hidemenu', $resource->getTVValue('HideMenu'));
              $resource->save();
              return '';


                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
                • 38290
                • 712 Posts
                Sounds like maybe Articles shouldn't hide the hide menu checkbox?
                  jpdevries
                  • 3749
                  • 24,544 Posts
                  Sure, but where's the fun in that? wink
                    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