Okay
  Public Ticket #2513308
Conditional DIV Display using ACF
Closed

Comments

  • Sascha Koeth started the conversation

    Hi!

    I am trying to build a justified mixed image and video carousel with the owl-carousel plugin within your Widget Creator using an ACF repeater with two subfields for the content. One for the image and one for the video.

    CSS and JS work fine.

    Now I try to setup the logic within the HTML field that "when there is a video in the acf repeater video field then use the video DIV, if not use the image DIV." So the carousel shows either an image or a video depending if there is a video uploaded to the item.

    Problem is, what ever I try to check against within the ACF Repeater item loop the carousel either uses only the Image DIVs for all items OR the video DIVs for all items, regardless of either there is a video for the specific item or not.


    Here is my testsetup (Based on your Justified Image Carousel Widget):

        <div class="owl-carousel owl-theme" style="direction:ltr; overflow:hidden;" id="{{uc_id}}">
        
        {% for item in current_post.cf_projekt_gallery %}
        
        {% if ".mp4" in "{{item.projekt_gallery_video}}" %}
         

     <div class="item-video">

        <video controls preload="none" width="auto" height="{{desktop_height}}" poster="{{item.projekt_gallery_image}}">

        <source src="{{item.projekt_gallery_video}}" type='video/mp4' />
        </video>
        </div>

        {% else %}
          <div class="item" style="position:relative;">
        <a ><img src="{{item.projekt_gallery_image}}" style="width:auto;"></a>
        </div>

        {% endif %}
          
        {% endfor %}
        
        </div>

    Do you have an idea what I am doing wrong here?

    Thanks!

  • Sascha Koeth replied

    Solved it:

    No {{ }} within {% %} statements!