ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Building a conditional snippet

June 17, 2010 5:55pm

Subscribe [1]
  • #1 / Jun 17, 2010 5:55pm

    qaswa

    9 posts

    I’m looking for a way to create conditional snippets (or other global reference). Ideally my template markup would look something like this:

    {if has_flash}DO-THIS{if:else}DO-THAT{/if}

    I tried creating a snippet with this code just to see if I can evaluate some PHP and write true or false:

    {if <? echo(strstr($_SERVER['HTTP_ACCEPT'], 'application/x-shockwave-flash')) ?> == 'true'}TRUE{if:else}FALSE{/if}

    This didn’t work and Since I have very little PHP experience, I’m not sure how to write this properly. And if it did work, who to make it into a snippet that also functioned as a conditional - if that’s even possible.

    Any thoughts?

    [Mod Edit: Moved to the How to forum]

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases