user4752928
user4752928

Reputation:

Not show DIV when no input value for template-variable in MODx

My blog posts have either a VIDEO or an IMAGE, never both. VIDEO and IMAGE are both template-variables in MODx Evolution CMS. Now ALWAYS, a DIV section (be it blank space/area) for an image will show and below that a DIV for a video. I want only the image to show provided I input a template-variable for an image, and then no blank space for the video DIV. Similarly, when I input a template variable for a video, then I do not want a blank area/space for the DIV image space to show.

DIV for image:

<div class="image">
<img src="[*image*]">
</div>

DIV for video:

<div class="well">
<video width="400" controls>
 <source src="[*video*]" type="video/mp4">
  <source src="[*video*]" type="video/ogv">
</video>
   </div>

How to display the DIV when I input an IMAGE and thus not show any space for the VIDEO DIV? Or how to display the DIV when I input a VIDEO and thus not show any space for the IMAGE DIV? Some IF-THEN rule?

Upvotes: 0

Views: 247

Answers (1)

user4752928
user4752928

Reputation:

Problem solved by using the PHx extra and this code...

[+phx:if=`[*video*]`:ne=``:then=`<div class="well">
<video controls="" width="400">
 <source src="[*video*]" type="video/mp4">
  <source src="[*video*]" type="video/ogv">
</video></div>`+]
        </div>

Upvotes: 1

Related Questions