We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 23344
    • 31 Posts
    I know I’ve been hitting the forums hard lately, but I’ve been on a big project and I’m learning a WHOLE BUNCH.

    Say I have a contact form, and it feeds from keys I made in my context. Like:

    Phone: [[++phone]]<br/>
    Fax: [[++fax]]<br/>
    E-mail: [[++email]]<br/>
    


    But say there is no fax set. Rather than having "Fax:" sitting there looking stupid, is there a way I can do an isset type conditional or something that would not display the whole line if the value is not set?
      • 18373 ☆ A M B ☆
      • 3,141 Posts
      [[+fax:notempty=`Fax: [[+fax]]`]]
      It’s called an output modifier / filter. It’s in the RTFM if you just search for output filter.

      Note that you should be using placeholder syntax [[+blah]], and not system setting syntax: [[++blah]] wink

        Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

        Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.
        • 23344
        • 31 Posts
        Quote from: Mark at Mar 03, 2011, 06:32 PM

        [[+fax:notempty=`Fax: [[+fax]]`]]
        It’s called an output modifier / filter. It’s in the RTFM if you just search for output filter.

        Note that you should be using placeholder syntax [[+blah]], and not system setting syntax: [[++blah]] wink

        Thanks. Well see I didn’t know the term to search it. Modx’s renders and filters don’t come natural to me... well anything beyond kindergarden PHP doesn’t sit well with me.

        But I try.
          • 18373 ☆ A M B ☆
          • 3,141 Posts
          It’s good that you ask smiley

          MODX is quite easy to get grips on, but like anything you need to know the terminology first.

          Did you have a look at the Quick Start? http://modx.com/learn/quickstart/ Not everything’s in there - but the basics of the basics are. I also wrote an article I called "MODX - MOD what?" which is a similar basic introduction: http://www.markhamstra.nl/modx/general/mod-what.html

          Near the summer we’ll have two amazing books out (at least: that’s my expectations atm, we’ll see how Bob & Shawn will do :p) which covers everything from start till end. Those will probably become invaluable.


          Oh, you could’ve also used the "If" snippet for conditional display, but I personally find output filters easier to use and I *think* they’re faster since they don’t involve calling a snippet, but are built in.
            Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

            Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.