We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 32699 ☆ A M B ☆
    • 427 Posts
    Quote from: BobRay at Jul 08, 2013, 10:35 PM
    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:

    So would I Bob. I just wanted to keep it within what the original poster was doing.

    Sottwell,

    The dirty trick would be to create a chunk which is sent the id of the page and then spit out a return based on the number.

    The chunk would be called cached, thereby only hitting the system with multiple filter tests when the cache does not have the current page.

    The content of the chunk would be unchached....

    I so love MODX. SO many ways to do something.

    Sotwell probably had the best solution of all - create multiple templates and walk away. You can share the header and footer via a chunk...
      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
      • 4172
      • 5,888 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?

      Are you talking about this one?
      http://modx.com/blog/2012/09/14/tags-as-the-result-or-how-conditionals-are-like-mosquitoes/

      In short:
      Since modx is parsing from inside to outside, this technique is processing only the result of the conditional, because it figures the condition and puts the result into the outer tag before processing them.


      I think, you can also use the in_array-conditon with the if-snippet, but I would also prefer to use different templates in this case. To create conditions, depending of resource-ids is not the best solution.
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 28042 ☆ A M B ☆
        • 24,524 Posts
        Yes, that's it.
          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