We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 36573
    • 173 Posts
    Below is the div. On the resource I have a TV to insert an image. The div is styles with css with borders and such.
    What I would like to do is change the css to display:none if no image inserted. Any ideas would be great. I tried using javascript but could not get it to work.

    <div class="image">
        <img src="[*blogimage*]" width="240"/> 
        <br />
         <p>[*imagedescription*]</p>
    </div>
      Everything I know I learned on the internet. Saved me thousands in College tuition,
      • 4385
      • 372 Posts
      You need to use PHx - http://wiki.modxcms.com/index.php/PHx#Introduction

      .hideDiv {
      	display:none
      }
      
      
      <div class="image [*blogimage:eq=``:then=`hideDiv`*]">
          <img src="[*blogimage*]" width="240"/> 
          <br />
           <p>[*imagedescription*]</p>
      </div>
      


      You could also not output the div at all and put your div into a chunk called imageDivChunk.

      [*blogimage:ne=``:then=`{{imageDivChunk}}`*]
      
        DropboxUploader -- Upload files to a Dropbox account.
        DIG -- Dynamic Image Generator
        gus -- Google URL Shortener
        makeQR -- Uses google chart api to make QR codes.
        MODxTweeter -- Update your twitter status on publish.
        • 36573
        • 173 Posts
        Thanks that worked perfect.

        Although after reading the wiki I changed the ne to is so that if the image TV is "" then hide div. I’ll read more on this PHx. Is it available for the new revolution?
          Everything I know I learned on the internet. Saved me thousands in College tuition,
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          It’s built-in to Revo.
            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