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

    I was wondering how I can exclude a chunk from one of my pages. I’m new to Modx.

    Thanks!

      • 28042 ☆ A M B ☆
      • 24,524 Posts
      If the chunk tags are in the template, you’ll need to use a Template Variable instead. The TV can either replace the chunk altogether, or just be a check box to load the chunk or not. It can be set to load the chunk by default, then you would just edit the page where you don’t want it and clear the checkbox.

        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
        • 23275
        • 4 Posts
        Thanks for your help, will get cracking over the weekend, and report back.
          • 23018
          • 353 Posts
          Hi phixon.

          As Susan pointed out, use a TV to display the chunk on all sites.

          1. Create a new TV. For example "includeChunk" (go to Elements -> Manage Elements -> Template Variables -> Click "New Template Variable").
          2. Set the type to text, textarea or textarea(mini). It depends on the amount of information you have to insert.
          3. Set the default value to @inherit (see below).
          4. Make the TV available in all relevant templates.
          5. Safe the new TV.
          6. Include [*includeChunk*] in your templates to output its content.

          What is @inherit?
          You can make use of the @inherit binding to give a default content to the TV in all descendant pages (see http://wiki.modxcms.com/index.php/@INHERIT_Binding)

          So, if your project is organized like this:

          homepage
          *about
          *services
          **webdesign
          **print design
          *...

          adding the chunk to the TV inside "homepage" will automatically insert this chunk in all it’s children.

          If you are worried, editors might mess up your code, restrict the TV only to be modified by users with adminstrative rights and hide it from view to all other users with managermanager.

          Good luck,

          pepebe
            Homepage: pepebe.de | MODX snippets (and other stuff) at github: https://gist.github.com/pepebe
            • 23571
            • 223 Posts
            It would also be possible to use PHx if you are only wanting to exclude on a single page ID. Something like: [+phx:if=`[*id*]`:is=`1`:then=``:else=`{{Chunk}}`+]