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.

EE-Conditional doesn't in a PHP enabled template with input-parsing

November 12, 2008 11:23am

Subscribe [1]
  • #1 / Nov 12, 2008 11:23am

    Nico Smit

    48 posts

    I’m using the following template to generate (main)images in my webpage, based on the custom field ‘pages_topimage’. When the field has a value, the image is placed correctly, but somehow the conditional below ({if top_image}) isn’t working when the field doesn’t have a value. It outputs ” width= and not the second condition.

    PHP is set to YES and to input.

    <?php
    global $IN;
    $seg1 = $IN->fetch_uri_segment('1');
    $seg2 = $IN->fetch_uri_segment('2');
    $seg3 = $IN->fetch_uri_segment('3');
    if ($seg3!=null) {
    ?>
    {assign_variable:top_image="{exp:entrydata:field url_title='{segment_3}' field='pages_topimage' field_format='raw'}"}
    <?php
    }elseif ($seg2!=null) {
    ?>
    {assign_variable:top_image="{exp:entrydata:field url_title='{segment_2}' field='pages_topimage' field_format='raw'}"}
    <?php
    }else{
    ?>
    {assign_variable:top_image="{exp:entrydata:field url_title='{segment_1}' field='pages_topimage' field_format='raw'}"}
    <?php
    }
    ?>
    {if top_image}
    {top_image}
    {if:else}
    {root_url}resources/common_images/sfeer/sfeer-01.jpg
    {/if}
.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases