We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
  • This must have something to do with the parse order or something.
    [[!setPlaceholders]] // $modx->setPlaceholder('siteCssOverride', '/path/to/override.css');
    [[+siteCssOverride:default=`<link rel="stylesheet" href="[[+siteCssOverride]]" />`]] // this works, outputs <link> element
    [[+siteCssOverride:notempty=`<link rel="stylesheet" href="[[+siteCssOverride]]" />`]]//this doesn't work; no ouput
    


    :notempty seems to work fine for TVs and other elements, but not for placeholders. Is the placeholder value somehow empty at the time the filter is applied? Very confusing.

    • This works as a workaround to do what I want (show nothing if empty, show the value inside a <link> element if not empty):
      [[+siteCssOverride:if=`[[+siteCssOverride]]`:eq=``:then=``:else=`<link rel="stylesheet" href="/[[+siteCssOverride]]" />`]]

      • Running into the same problem in 2.0.7... while the workaround is a possibility, I’m also wondering why this wont work on placeholders...


        A similar (but slightly cleaner imo) workaround could be
        [[!+fi.error.email:isnot=``:then=`<br />[[!+fi.error.email]]`]]
          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.
          • 28215
          • 4,149 Posts
          You should make those placeholders uncached.
            shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com
          • I can’t talk for James, but it aint working for me uncached either...
              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.
              • 28215
              • 4,149 Posts
              [[!+fi.error.email:notempty=`<br />[[!+fi.error.email]]`]]


              Should work fine. I’ve tested that on multiple environments.
                shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com
                • 38297
                • 2 Posts
                I was struggling to get this working. Seems to be important to put the snippet call that sets the placeholder in the code before :notempty.
                  • 4955
                  • 32 Posts
                  i am getting nuts on that: using revo 2.4.4

                  [[!+blog-bild:if=`[[!+blog-bild]]`:ne=``:then=`[[!+blog-bild:phpthumbof=`w=213`]]`:else=`[[*box4-img:phpthumbof=`w=213`]]`]]


                  blog-bild placeholder is saved and fetched via getresources > chunk > tv in it containg a relative path to the image file.

                  [[!getResources?
                  &showHidden=`1`
                  &tpl=`blog-box-picture`
                  &limit=`1`
                  &includeTVs=`1`
                  &processTVs=`1`
                  &includeContent=`1`
                  &parents=`23`
                  &hideContainers=`1`
                  &resources=`-51`
                  &toPlaceholder=`blog-bild-en`
                  ]]


                  chunk > "blog-box-picture" is [[+tv.blog-bild]]

                  when blog-bild is empty i am getting a var_dumb out put. what am i dong wrong? [ed. note: charismeki last edited this post 11 years, 6 months ago.]
                    • 39932
                    • 483 Posts
                    I have found that the following works reliably after researching caching with my own issues.

                    [[!+placeholder:notempty=`[[+placeholder]]`]]

                    I am sure that the answer lies somewhere in the cached versus uncached dilemna regarding Snippets. Since I didn't see a clear answer on this, I must assume that others are still having problems with this. This also seems to keep with consistent for Properties and Chunks as well. The following all work reliably:

                    [[!snippet:notempty=`[[snippet]]`]]
                    [[!$chunk:notempty=`[[$chunk]]`]]
                    [[!*field:notempty=`[[*field]]`]]
                    [[!++setting:notempty=`[[*++setting]]`]]

                    While it is not necessary for all of the above, it does help provide a "standard of practice" that is simple to remember.

                    Note: After finding this, I also checked it with other modifiers that "weren't working". This seemed to provide more reliable results with those, as well. [ed. note: fuzzicallogic last edited this post 11 years, 1 month ago.]
                      Website: Extended Dialog Development Blog: on Extended Dialog
                      Add-ons: AJAX Revolution, RO.IDEs Editor & Framework (in works) Utilities: Plugin Compatibility List
                      Tutorials: Create Cross-Context Resources, Cross-Context AJAX Login, Template-Based Actions, Remove Extensions from URLs

                      Failure is just another word for saying you didn't want to try. "It can't be done" means "I don't know how".
                      • 36173
                      • 26 Posts
                      Hi Gang,
                      Likewise I have had intermittent problems with Output modifiers and ":notempty" :default etc, no resolution.

                      (a) the parser does not always correctly determine what "empty" means. It treats the number zero as empty for example.
                      (b) Tvs and placeholders fail intermittently on the empty tests.

                      It's a big minus to have to constantly think about this--PHP coding is not supposed to be easier. My workaround today was to make my values required. (allow blank = No)

                      FYI.