We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 28341
    • 43 Posts
    I’ve been trying to use Phx in order to show/not show pre/after-content of TV output. Like so -

    [+phx:if=`slideshow-image-1`:is=``:then=``:else=`<li><img src="./assets[*slideshow-image-1*]" width="958" height="270" /></li>`+]

    Also tried

    [+slideshow-image-1:isnotempty:then=`<li><img src="./assets[*slideshow-image-1*]" width="958" height="270" /></li>`+]

    Nothing’s displayed. I’m sure I have Phx running since I’m using Character Limit on some other pages. What am I missing? Or should I approach this in another way?
    I couldn’t find an easy method of including X images in a post so I created a couple of TVs, that’s why it looks like this.
      • 1778
      • 659 Posts
      Don’t you miss a slash between assets and [*slideshow-image-1*] ?

      /assets/[*slideshow-image-1*]... Not sure but it could be that...

      Cheers
        • 28341
        • 43 Posts
        No the reference is correct. I’ve tried with simply showing text messages just to confirm it’s not the image source.
          • 33976 ☆ A M B ☆
          • 571 Posts
          You’d better try with [+phx:if=`[*slideshow-image-1*]`:is=``:then=``:else=`your output`+] to indicate that you want to check the TV

          Good luck smiley
            • 28341
            • 43 Posts
            Oh! Well, I tried your suggestion and it still doesn’t work... this is driving me nuts!

            Here’s what I’m currently using:

            [+phx:if=`[*slideshow-image-1*]`:is=``:then=``:else=`<img src="./assets[*home-slideshow-1*]" width="958" height="270" />`+]

            Tried outputting text if empty just to be sure. Still nothing. And there IS content in the TV.
              • 3749
              • 24,544 Posts

              Try using ifempty instead of =.
                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
                • 4310
                • 2,310 Posts
                You could do it as a snippet :
                <?php
                $tv = $modx->getTemplateVarOutput(true, $modx->documentIdentifier);
                $field = $tv['home-slideshow-1'];
                if(!empty($field)){
                $output = '<img src="./assets'.$field.'" width="958" height="270" />';
                }
                return $output;
                ?>
                  • 28341
                  • 43 Posts
                  The only method that worked was the snippet version. I guess what you’re suggesting is that I make a genereal snippet that checks for empty TVs and not one for each wink That would be a good thing to use throughout the page. It’s just that I’m very new to snippets, not sure how I could check each TV? By a parameter (&tvHasContents=`yourTV`) perhaps?
                    • 28341
                    • 43 Posts
                    Solved. I installed PHx (which is weird considering I have other PHx functions running through the core installation) then tried [+phx:if=`[*slideshow-image-1*]`:is=``:then=``:else=`<img src="./assets[*slideshow-image-1*]" width="958" height="270" />`+]
                      • 33337
                      • 3,975 Posts
                      Ditto and some other snippets come with Phx integrated in them, but to globally access PHx it has to be installed. smiley
                        Zaigham R - MODX Professional | Skype | Email | Twitter

                        Digging the interwebs for #MODX gems and bringing it to you. modx.link