We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 16182
    • 56 Posts
    Using modx Evo a container unfortunately seems to also be a page with content. I’m looking for a way to avoid that.

    Example:

    I’d like to setup a menu on the site, which is 1 level deep, like
    Products
     - prod 1
     - prod 2
    
    Services
     - service 1
     - service 2
    
    Company
     - about us
     - contact


    I would like the top-level items (Products, Services, Company) to be containers holding the other pages. But I don’t want to give these containers any content. All they should do is contain and thus structure the actual pages.

    The menu would be generated by wayfinder (and YAMS for multilingual stuff).

    This all works fine, but unfortunately the top-level items are clickable in the menu and lead to empty pages. Even if I tweak the wayfinder templates in a way to not link the top-level menu entries, MODx will still create pages for them.

    I’m aware of the firstchildredirect but that together with the tweaked wayfinder templates is only a workaround.

    Question:

    Is there any way to make these containers just that: a container?
      • 3749
      • 24,544 Posts
      There is no way to make them not be documents, but you could probably put a snippet on them that would redirect the user back to the previous page by using

      $modx->sendRedirect($_SERVER['HTTP_REFERER']);


      Maybe someone else has a better idea. You could also put submenus on them pointing to their children.
        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
        • 16182
        • 56 Posts
        Thanks for the swift reply!

        Putting such a snippet on still leaves them in their state as valid documents. That has a few unwanted side-effects. E.g., in an automatically generated sitemap these pseudo-documents would still show and attract the Google bot.

        Essentially, I would need a state between published and unpublished. The content part should be unpublished, but structure-wise they should still live. Maybe there is a possibility to write an extension/plugin that does this with the help of an extra template variable?
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          Wayfinder has a template for parent items. Just don’t put a link in the tpl.
            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
            • 16182
            • 56 Posts
            Yes, Susan, I know. That’s what I meant when I said

            Even if I tweak the wayfinder templates in a way to not link the top-level menu entries, MODx will still create pages for them.

            The problem remains that MODx still creates documents where it shouldn’t.

            Maybe I look into creating a plugin that solves this issue. Do you think it is possible to jump in early enough in the execution event order to prevent the document from being delivered and do a 404 instead? Of course without compromising Wayfinder to generate the menus.
              • 16182
              • 56 Posts
              Hm, to do it properly, a new document type would be necessary - a bit like a weblink type (which also doesn’t have content). For the time being I solved this with the workaround of making the container a weblink pointing to my 404 error document. For the sitemap I use a filter to exclude it and for the menu I use a wayfinder template to leave out the link as Susan suggested. the sitemap filter actually uses the setting of "non-searchable" to distinguish from valid weblinks that actually should appear in the sitemap.

              A bit complicated in the setup and not very flexible for sites that might have mixture of containers with and without content, but for me it is fine.
                • 4971
                • 964 Posts
                Just to get more info...

                why do you care if MODx makes a document of a container
                if your users dont have access (click access) to it?

                if your concern in the Manager you can use permissions to
                keep your client/editors from accessing that document...
                  Website: www.mercologia.com
                  MODX Revo Tutorials:  www.modxperience.com

                  MODX Professional Partner
                  • 16182
                  • 56 Posts
                  Concern was mostly for the sitemap, which shouldn’t contain stuff that’s not relevant for the Google bot.

                  Plus, as I’m using YAMS, I was hesitating to deviate from the standard YAMS template for Wayfinder - as this is just another thing to keep in mind when YAMS is changing.

                  And finally, I was wondering if I was just overlooking something as this seems to be a rather standard request considering current standard webdesigns - but I couldn’t find an obvious solution.
                    • 4971
                    • 964 Posts
                    For the sitemap maybe you can use a "noindex, nofollow" in those pages with a SEO TV.

                    Sorry, I have no experience with YAMS...
                      Website: www.mercologia.com
                      MODX Revo Tutorials:  www.modxperience.com

                      MODX Professional Partner
                      • 16182
                      • 56 Posts
                      Ah, just discovered one additional thing thanks to the wonderful ebook http://modxcms.com/forums/index.php?action=dlattach;topic=34176.0;attach=9315 about Wayfinder.

                      I was on a wrong track with the parent template of Wayfinder (hey Susan, you were on that track too ;-). The author of Wayfinder actually had thought about this container issue as well and called these containers without content "categories". There is a special category template that Wayfinder can use called "categoryFoldersTpl"!

                      To mark a container as category, Wayfinder either expects the template to be blank (doesn’t work in my case as I use YAMS with multiple languages and corresponding template variables) or the link attributes to contain rel="category". If you put that in, the category template is applied automatically only for those containers that actually are categories and not for all as it would have happend with the parent template.

                      Couple that with a good filter for the sitemap.xml plus making the container a weblink to the error document and the problem is solved.