Page 1 of 1

[solved] CompanyDirectory - displaying only checked boxes

Posted: Tue Mar 06, 2012 9:24 pm
by ACDS
I have a number of field definition entries as checked boxes (options of what type of work a company is doing...which could have multiple entries).

I am trying to only display the values of the entries of the checkbox value is 'true' in the Details Template. Currently the code below calls all the entries and puts 'true' or 'false' behind the entry (as it obviously should:

Code: Select all

{if isset($entry->fields) }
  {foreach from=$entry->fields key='field_name' item=customfield}
	{$customfield->name}: {$customfield->value}<br />
  {/foreach}
{/if}
I have tried calling each of the entries individually with:

Code: Select all

{if $entry->customfieldsbyname.Yourname ne ''}
{$entry->customfieldsbyname.Yourname}
{/if}
But this is also not working (nothing is displayed).

I have CMSMS 1.10 and CD 1.13.

Any advice would be great.

Thanks
Dewald

Re: CompanyDirectory - displaying only checked boxes

Posted: Tue Mar 06, 2012 10:01 pm
by uniqu3
Did you try?

Code: Select all

{if isset($entry->fields) }
  {foreach from=$entry->fields key='field_name' item=customfield}
   {if $customfield->value != 'true'}
       {$customfield->name}: {$customfield->value}<br />
   {/if}
  {/foreach}
{/if}

Re: CompanyDirectory - displaying only checked boxes

Posted: Wed Mar 07, 2012 5:35 am
by ACDS
Thank you very much unique3.

I had to change the "true" to "false" to just display the true values:

Code: Select all

{if isset($entry->fields) }
  {foreach from=$entry->fields key='field_name' item=customfield}
   {if $customfield->value != 'false'}
    <li>{$customfield->name}<br /></li>
   {/if}
  {/foreach}
{/if}
I then also removed the display of "true" and included all true customfields to be displayed as a list.

Thank you very much for this help!
Dewald