0

I am trying to set up a slider in ExpressionEngine which will display a video if the video embed code exists, otherwise it will display an image slider. Currently, I am not able to hide the image slider if the video code exists(but the video does get placed on the page).

Here is my code:

{slider}
    {if video}
            {video}
    {if:else}
        {if total_rows > "1" && row_count == "1"}
            <div id='news_slider'>
        {/if}
            <img title="{img_title}" src="{img}" />
        {if total_rows > "1" && row_count == total_rows}
            </div>
        {/if}
    {/if}
{/slider}

Any ideas? Thanks!

1 Answer 1

2

Have you tried this? The difference is on Line 2. It does mean you're running the conditional against the entire embed string rather than the variable but it may work.

{slider}
    {if "{video}"!=""}
            {video}
    {if:else}
        {if total_rows > "1" && row_count == "1"}
            <div id='news_slider'>
        {/if}
            <img title="{img_title}" src="{img}" />
        {if total_rows > "1" && row_count == total_rows}
            </div>
        {/if}
    {/if}
{/slider}

I also found out from the OP that this is running EE 2.5.5 and Pixel and Tonic Matrix. I wrote a prototype alternative in Grid and advised he upgrades to that.

8
  • Hmmm it seems like if I do it that way ExpressionEngine is treating the raw embed code as the conditional variable. I am getting: "Message: Invalid EE Conditional Variable"
    – APAD1
    Commented Mar 12, 2014 at 18:41
  • Could you clarify what you mean?
    – Mutual
    Commented Mar 12, 2014 at 18:43
  • So instead of checking if "video" is set, it's checking if "<iframe width="560" height="315"...." is set. Basically it's treating the raw embed code as the variable.
    – APAD1
    Commented Mar 12, 2014 at 18:44
  • 1
    Let me have a play and I'll get back to you in 5.
    – Mutual
    Commented Mar 12, 2014 at 18:48
  • 1
    let us continue this discussion in chat
    – Mutual
    Commented Mar 12, 2014 at 18:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.