Problems, need help? Have a tip or advice? Post it here.
6 posts Page 1 of 1
Hello, I am trying to set up template which will allow my client to paste in youtube/vimeo embed code to display a video on the front end. The video will be contained within a particular div (required to ensure responsiveness). However I want it so that if no embed code is entered, then nothing will show on the front end - ie. the containing div will not show.

Originally I set the video up as a repeatable region and followed this thread :http://www.couchcms.com/forum/viewtopic.php?f=4&t=8256 but have now realised that not_empty doesn't work with textarea which is why my code isn't not working.

This was my code:

<cms:capture into='my_video'>

<cms:show_repeatable 'video' >
<cms:if "<cms:not_empty videolink />" >
<cms:show videolink />
</cms:if>
</cms:show_repeatable>

</cms:capture>

<cms:if "<cms:not_empty my_video />" >
<div class="video">
<cms:show videolink />
</div>
</cms:if>

Can you suggest an alternative way that I could achieve the same kind of thing (ie. if no video embed code is entered, the containing div will not appear)? I don't necessarily need it to be repeatable region as there will only ever be one video per template getting posted...
Hi,

Please try the following -
Code: Select all
<cms:capture into='my_video'>
    <cms:show_repeatable 'video' >
        <cms:if videolink >
            <cms:show videolink />
            <cms:set has_video='1' 'global' />
        </cms:if>
    </cms:show_repeatable>
</cms:capture>

<cms:if has_video>
    <div class="video">
        <cms:show my_video />
    </div>
</cms:if>

Please let me know if it helps.
It works perfectly - thank you so much!!! :D :D :D
I hope you don't mind but I have another question relating to the same issue. I have also used the code in this post viewtopic.php?f=4&t=8256 on a galleria gallery on my page. So that if the user doesn't upload any images, the galleria div does not show. It's working perfectly, however the Galleria plugin displays an error message on the front end if there has been no images uploaded unto the gallery, as obviously it is looking for the galleria div, but it's not there. I was wondering if there is a way I can put the code that calls galleria in a snippet/or php include, and then use couch to only display the snippet if there is content in the gallery, so that I don't get the error messge (it seems that you can't completely disable debug messages within Galleria).

This is the code that I am using for the gallery which works:

<cms:capture into='my_slideshow'>
<div class="galleria">
<cms:show_repeatable 'gallery' >
<cms:if "<cms:not_empty gal_image />" >
<img class="rsImg" src="<cms:show gal_image />" alt="" />


<cms:set has_image='1' 'global' />
</cms:if>
</cms:show_repeatable>
</div>
</cms:capture>

<cms:if has_image >
<cms:show my_slideshow />
</cms:if>

And then this is the code that I would ideally like to put in an include/snippet and only include it on the page if there is content in the gallery:

<script src="../galleria/themes/classic/galleria.classic.min.js"></script>
<script>

// Load the classic theme


Galleria.configure({
imageCrop: false,
showCounter:false,
showImagenav:false,
debug: false,
transition: 'fade'
});


Galleria.run('.galleria');

</script>

Is it possible?
Something like this should work, just add the code you want to include on the page of the gallery in the conditional to only load if it's not empty

Code: Select all


<cms:capture into='my_video'>
    <cms:show_repeatable 'video' >
        <cms:if videolink >
            <cms:show videolink />
            <cms:set has_video='1' 'global' />
        </cms:if>
    </cms:show_repeatable>
</cms:capture>

<cms:if has_video>

<script src="<cms:show k_site_link />galleria/themes/classic/galleria.classic.min.js"></script>
<script>

    // Load the classic theme
   
   
    Galleria.configure({
    imageCrop: false,
    showCounter:false,
    showImagenav:false,
    debug: false,
    transition: 'fade'
});


    Galleria.run('.galleria');

    </script>   

</cms:if>


That's brilliant, working now - really appreciate you help! :-D
6 posts Page 1 of 1