We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 40643
    • 36 Posts
    I am using Modx 2.2.8 on Linux\cPanel

    I am using the current version of Migx to create 3 boxes at the beneath the content area. I am calling the chunk in the content area of the page. Like so:

    [[getImageList?
    &tvname=`contactTV`
    &tpl=`tpl_contactinfo`
    &docid=`11`
    ]]
    This is with the contact form.
    Then in my main template I have the following for the 3 migx boxes:
    <!--start content-->
    <section id="content" class="clearfix">

    <!--section top-->
    [[*id:is=`5`:or:is=`6`:or:is=`7`:then=`<div class="grid_12">[[*content]]</div>`:else=`[[*content]]`]]

    <!--end section top-->
    [[$tpl_contentbottom]]
    </section>
    <!--end content-->
    </div>

    I would like to change the div for 3 pages with this [[*id:is=`5`:or:is=`6`:or:is=`7`:then=`<div class="grid_12">[[*content]]</div>`:else=`[[*content]]`]]
    if the page is not 5,6 or 7 then put in the main content area with no div.

    When I use this my contact page chunk disappears.

    Can anyone help with a solution?

    Thanks

    Lisa [ed. note: lchestnut last edited this post 13 years, 3 months ago.]
      • 13643
      • 44 Posts
      Quote from: lchestnut at Jun 24, 2013, 01:17 PM
      I would like to change the div for 3 pages with this [[*id:is=`5`:or:is=`6`:or:is=`7`:then=`<div class="grid_12">[[*content]]</div>`:else=`[[*content]]`]]
      if the page is not 5,6 or 7 then put in the main content area with no div.

      I'm not sure I understand what you're trying to do, but if you want a content element, such as a div, to appear on certain pages but not on others, you might consider using a separate template for those pages, instead of output filters. In my experience, chained output filters such as you have proposed above can be problematic and unpredictable.

        • 28042 ☆ A M B ☆
        • 24,524 Posts
        Indeed. I often amuse myself with shoehorning an entire site into one template, but it's usually far more trouble than it's worth. I do try to keep the templates to a minimum, but I usually end up with 6-8 templates for a fairly complex site.

        Another method of doing something like what you have is to use chunks and a radio button TV for choosing between them. In your case, the default would be the radio button to load a chunk with just [[*content]] in it, while the other option would be for a chunk with the div container. Most resources will get the plain content. Then on resource #5, #6, #7 just select the other radio button.
          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
          • 40643
          • 36 Posts
          Many thanks to both of you. I have been trying to keep things as simple as possible for my clients (tech savvy they are not). I will try these suggestions out.

          I appreciate your time.
            • 9207 ☆ A M B ☆
            • 2,475 Posts
            I agree with the others: chained output filters can be trouble.

            I wrote a plugin to help catch syntax errors -- it might be helpful in this case: http://modx.com/extras/package/syntaxchecker
              • 32699 ☆ A M B ☆
              • 427 Posts
              Quote from: Everettg_99 at Jul 05, 2013, 11:09 AM
              I agree with the others: chained output filters can be trouble.

              I used to fall victim to this years ago. Once you understand each output filter is in effect potentially changing the original value to be handed off to the next filter it gets much easier.
                Get your copy of MODX Revolution Building the Web Your Way http://www.sanitypress.com/books/modx-revolution-building-the-web-your-way.html

                Check out my MODX || xPDO resources here: http://www.shawnwilkerson.com
                • 40643
                • 36 Posts
                Thanks all for your input. I am really trying to get the hang of the output modifiers. I just wish they were a little simpler to use. If I have more than one condition to satisfy then most times they havent worked. I will keep working with Modx and learning.

                Thank you.

                Lisa
                  • 32699 ☆ A M B ☆
                  • 427 Posts
                  Lisa there is always longhand:

                  <div class="[[*id:is=`5`:then=`grid_12`]][[*id:is=`6`:then=`grid_12`]][[*id:is=`7`:then=`grid_12`]]">[[*content]]</div>
                  


                  or

                  <div class="[[*id:is=`5`:or:is=`6`:or:is=`7`:then=`"grid_12"`:else=`"someotherclass"`]]">[[*content]]</div>
                  
                    Get your copy of MODX Revolution Building the Web Your Way http://www.sanitypress.com/books/modx-revolution-building-the-web-your-way.html

                    Check out my MODX || xPDO resources here: http://www.shawnwilkerson.com
                    • 3749
                    • 24,544 Posts
                    Shawn's approach will be much faster. The problem with your original code is that the entire content of the page will be parsed twice, for no reason.

                    BTW, I would do it with a snippet snippet:

                    <div class="[[!GetClass]]">[[*content]]</div>



                    <?php
                    /* GetClass snippet */
                    
                    switch($modx->resource->get('id') {
                        case '5':
                        case '6':
                        case '7':
                           $output = 'grid_12';
                           break;
                        default:
                           $output = 'someotherclass';
                    }
                    return $output;
                    


                      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
                      • 28042 ☆ A M B ☆
                      • 24,524 Posts
                      The problem with output modifiers is that every condition is checked, even if the first one resolves to true. So if you have several options to your condition it evaluates every one of them, slowing things down. Jason pointed out one way of working around this, although I still don't quite understand exactly what it's doing. It involves embedding the conditional in the chunk or TV tags. I can't find the reference to this, though. Maybe somebody else knows what I'm referring to?
                        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