Page 1 of 1

Bug in News module version 2.15.1?

Posted: Sun Jun 28, 2015 3:19 pm
by 10010110
It appears that in the latest version of the News module $entry->fields is always set (or never empty), even if there is nothing in that field. I don’t think this used to be the case before. I have a file upload field and this is the code in my summary template:

Code: Select all

{if isset($entry->fields)}
	{foreach from=$entry->fields item='field'}
<div class="extrafeld">
		{if $field->type === 'file'}
			{assign var='fileArray' value='.'|explode:$field->displayvalue}
			{if $fileArray|end|lower === 'png' || $fileArray|end|lower === 'jpg' || $fileArray|end|lower === 'jpeg' || $fileArray|end|lower === 'gif'}
				{cms_module module="CGSmartImage" src="{$entry->file_location}/{$field->displayvalue}" alt="" filter_resize="w,200"}
			{elseif $fileArray|end|lower === 'pdf'}
		<object data="{$entry->file_location}/{$field->displayvalue}" type="application/pdf">
			<a href="{$entry->file_location}/{$field->displayvalue}">{$field->displayvalue}</a>
		</object>
			{/if}
		{else}
			{$field->name}: {$field->displayvalue}
		{/if}
</div>
	{/foreach}
{/if}
And if I do a check inside the loop for:

Code: Select all

 {if !empty($field->displayvalue)}
it always returns false, even if a value is set.

Am I doing something wrong or is there a bug in the News module?

Re: Bug in News module version 2.15.1?

Posted: Sun Jun 28, 2015 5:17 pm
by Jeff
Also check "field->value"

Code: Select all

{if !empty($field->displayvalue)}
    {$field->displayvalue}
{elseif !empty($field->value)}
    {$field->value}
{/if}

Re: Bug in News module version 2.15.1?

Posted: Tue Jun 30, 2015 7:34 pm
by 10010110
Thanks, checking for $field->value appears to do it. But why do I have to implement that now? I seem to recall that with the previous version the check for isset($entry->fields) already took care of that, i. e. if a field didn’t have a value nothing was shown.