Bug in News module version 2.15.1?

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Locked
10010110
Translator
Translator
Posts: 224
Joined: Tue Jan 22, 2008 9:57 am

Bug in News module version 2.15.1?

Post 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?
Jeff
Power Poster
Power Poster
Posts: 961
Joined: Mon Jan 21, 2008 5:51 pm

Re: Bug in News module version 2.15.1?

Post by Jeff »

Also check "field->value"

Code: Select all

{if !empty($field->displayvalue)}
    {$field->displayvalue}
{elseif !empty($field->value)}
    {$field->value}
{/if}
10010110
Translator
Translator
Posts: 224
Joined: Tue Jan 22, 2008 9:57 am

Re: Bug in News module version 2.15.1?

Post 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.
Locked

Return to “CMSMS Core”