We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 28120
    • 380 Posts
    I’m trying to display the Long Title if defined else the Page Title

    Struggling with the syntax so any help on the following appreciated

    <h1 class="h1-top">[[If? &[[*longtitle]]> `` &then=`[[*longtitle]]` &else=`[[*pagetitle]]` ]]</h1>

    or

    <h1 class="h1-top">[[If? &[[*longtitle]]:notempty &then=`[[*longtitle]]` &else=`[[*pagetitle]]` ]]</h1>
      • 28215
      • 4,149 Posts

      Without If:
      <h1 class="h1-top">[[*longtitle:if=`[[*longtitle]]`:eq=``:then=`[[*pagetitle]]`:else=`[[*longtitle]]`]]</h1>
      


      With If:
      <h1 class="h1-top">[[!If? &subject=`[[*longtitle]]` &operator=`empty` &then=`[[*pagetitle]]` &else=`[[*longtitle]]`]]</h1>
      
        shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com
        • 28120
        • 380 Posts
        Thanks

        It’s apparent I totally misunderstood the syntax smiley

        You’re first offering worked for me but the one with IF showed nothing? The IF one seems a bit more friendly for code reading later so I’d like to use this if I can.
          • 32674
          • 101 Posts
          Quote from: sparkyhd at Aug 17, 2010, 08:38 AM

          Thanks

          It’s apparent I totally misunderstood the syntax smiley

          You’re first offering worked for me but the one with IF showed nothing? The IF one seems a bit more friendly for code reading later so I’d like to use this if I can.

          Could be you didn’t download & install the ’If’ extra component? http://modxcms.com/extras/package/600

          ’If’ you did install, ignore me.
            • 28120
            • 380 Posts
            Wow - there’s a package for ’IF’ shocked

            It now works. Even though I’m close to finishing my first Revolution site I’ve still got so much to learn!

            Thanks
              • 17499 ☆ A M B ☆
              • 872 Posts
              Quote from: sparkyhd at Aug 17, 2010, 09:10 AM

              Wow - there’s a package for ’IF’ shocked

              It now works. Even though I’m close to finishing my first Revolution site I’ve still got so much to learn!

              Thanks

              "If" is package yes.

              You mistake it with the output filters which are phx directly integrated in MODx Revo.
                • 4971
                • 964 Posts
                So what is the difference in the functionality between
                if form the Package IF and
                if from the PHx functionality now embedded in Revo?
                  Website: www.mercologia.com
                  MODX Revo Tutorials:  www.modxperience.com

                  MODX Professional Partner
                  • 17499 ☆ A M B ☆
                  • 872 Posts
                  Quote from: charliez at Aug 17, 2010, 09:16 AM

                  So what is the difference in the functionality between
                  if form the Package IF and
                  if from the PHx functionality now embedded in Revo?

                  I think that if was provided before phx was integrated.

                  splittingred as given a good example above (the without if code is with output filters)
                    • 4971
                    • 964 Posts
                    a ok... yes, I saw the examples and they are practically the same,
                    hence my question...

                    I am used to PHx and if they offer the same functionality I wont
                    need the IF package...
                      Website: www.mercologia.com
                      MODX Revo Tutorials:  www.modxperience.com

                      MODX Professional Partner
                      • 27913
                      • 2 Posts
                      In the filter source php (modoutputfilter.class.php) i see the following comment:
                      /* conditional operators */
                      /* @todo these conditionals should be removed because there are cleaner ways to do this now */


                      Can i know, will be conditional operators removed in a future versions or no?
                      Should i use If snippet or i can use output filter (it looks better for me smiley )?
                        With best regards, Neil.