[solved] CompanyDirectory - displaying only checked boxes

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
ACDS
Forum Members
Forum Members
Posts: 17
Joined: Tue Jul 12, 2011 12:02 pm

[solved] CompanyDirectory - displaying only checked boxes

Post 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
Last edited by ACDS on Wed Mar 07, 2012 5:35 am, edited 1 time in total.
uniqu3

Re: CompanyDirectory - displaying only checked boxes

Post 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}
ACDS
Forum Members
Forum Members
Posts: 17
Joined: Tue Jul 12, 2011 12:02 pm

Re: CompanyDirectory - displaying only checked boxes

Post 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
Post Reply

Return to “Modules/Add-Ons”