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?
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>