We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 22019
    • 390 Posts
    Bob is referring to the conditional content part of the Revolution manual
    http://rtfm.modx.com/display/revolution20/Input+and+Output+Filters+%28Output+Modifiers%29

    Output modifiers will perform an action on a placeholder or other content variable - eg formatting dates, creating thumbnails or 100 and one other things (not all documented yet)

    Conditional output modifiers try to perform logic as well as formatting, eg [[+introtext:if=`[[*id]]=29`:then=`<strong>Hello</strong>`:else=`<em>World</em>`]] NOTE that example probably doesn’t work as I’m riffing here. They do not do this as efficiently as the If extra, and both methods are slower than writing a custom snippet that checks for a specific set of circumstances.

    Math output modifiers do, erm, maths - ie calculate a new value based on the input value. I’ve never used them in a live environment, so I can’t really comment.

    I think the general principle Bob is getting at is that a specific snippet will usually outperform a generic one (although this may be a marginal performance gain), and both will outperform the output modifiers. It’s partly to do with parse order, and partly to do with the extra overhead of loading classes and methods that are more ’able’ than strictly required.
      Writer > E-consultant > MODx developer || Salesforce || modx 2.x || PHP 5.2.13 || MySQL client 5.0.86
      • 3749
      • 24,544 Posts
      Well said odeclass. The conditional modifiers (if, then, else) take a lot of processing because MODX has to figure out which modifiers are present (and there are a ton of them) and then process the heck out of them to get sensible PHP code out of the string that was sent in the tag.

      The filter() method of the modoutputfilter class is about 500 lines of code. Your custom snippet would be ten lines at the most and often just two or three.
        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
        • 36782
        • 109 Posts
        Hi
        This is great info, and maybe all we need is a lightly-moderated open sticky here on the community, or something? Spread out the work?

        Of course, I'd be coming out on the sweet side of that bargain! haha

        Just a quick question, Bob - does what you posted apply to all of the output modifiers, or just to the conditional types?
        And I'm assuming that :notempty counts as conditional? Or is that only if I follow it up w/ :then ?

        Interesting, though. I think I'm guilty of over-using modifiers!
          • 3749
          • 24,544 Posts
          All the output modifiers will require more parsing than a custom snippet, but the complex conditionals and math modifiers are particularly heavy.

          That said, in many cases we're talking about fairly trivial time differences that might not be noticeable unless you have a lot of modifiers on the same page.

          The "If" snippet, BTW, is a relatively efficient alternative since it cuts out the step of identifying which filter is being used and has a limited number of possible properties to process.
            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
            • 36782
            • 109 Posts
            Cool, thanks for that.
            I do tend to use :notempty quite heavily to avoid empty HTML elements like <p> and <h2>, etc.

            Good to know about "If"; I had thought that built-in modifiers must be more efficient, so I dropped "If" along w/ Evo.

            See? this thread is turning up some excellent info. I'll bookmark it as "MODx Optimization Tutorial" smiley