We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 36582
    • 463 Posts
    I'm trying to display a message or style a blog post in a particular way when a certain tag is use in a blog post.

    So…

    If articles tag reads "Thank You" then display message "Cheers"

    … display message could mean display background image, image or text etc.

    The following example is not correct but might help to explain further…

    [[+tv.articlestags:=`Thank You`:then=`Cheers`]]


    I'd be grateful if anyone could point me in the right direction.
      Web site design in Nottingham UK by Chris Fickling http://www.chrisficklingdesign.co.uk
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      Add "is" in there:
      [[+tv.articlestags:is=`Thank You`:then=`Cheers`]]

      Think of output modifiers as function names. The "is" is the name of the function that does comparison. isequalto, isequal, equalto, equals, is, eq will all do the same thing.

      http://rtfm.modx.com/revolution/2.x/making-sites-with-modx/customizing-content/input-and-output-filters-%28output-modifiers%29#InputandOutputFilters%28OutputModifiers%29-Conditionaloutputmodifiers

      I use this so much that I have it in my browser's bookmark toolbar, right next to BobRay's Objects page.
        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
        • 3749
        • 24,544 Posts
        It's also a good practice to use both a ":then=" and an ":else=" whenever you use a conditional modifier. Sometimes it doesn't matter whether you have the ":else=", but often it does.
          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
          • 36582
          • 463 Posts
          Thank you very much for your replies. I'm almost the with my understanding but now I'm wondering if this is possible.

          What i'd like to do is add a css style to a div according to how the Article is tagged. So if an article is tagged "Thank You", style that article summary in a certain way - this is what I have…

          <div class="[[+tv.articlestags:is=`Thank You`:then=`cheers`:else=`nocheers`]]"> content </div>


          I suppose the crux of it is that I need to replace ':is' with ':contains'

          …however reading the documentation I don't think it will work. In getResources there is the possibility to use…

          `articlestags==%[[*somethingToCompareTo]]%`


          …to achieve this (where *filter means a value that is contained within). Am I on the wrong track?
            Web site design in Nottingham UK by Chris Fickling http://www.chrisficklingdesign.co.uk