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}