Page 2 of 2

Re: [Solved] Is it possible to order Field Definitions in Co

Posted: Wed Jul 13, 2011 1:28 pm
by ACDS
M@rtijn just a follow-up...

In terms of the coding...I am not sure which code to leave an which to take out. I get all kinds of errors on my front end.

Do I leave the following as is:

Code: Select all

{if $customfieldscount gt 0}
   {foreach from=$customfields item=customfield}
      {$customfield->name}: {$customfield->value}<br />
   {/foreach}
{/if}
and then just add the rest below?

Code: Select all

{if $entry->customfieldsbyname.Yourname ne ''}
{$entry->customfieldsbyname.Yourname}
{/if}

Re: [Solved] Is it possible to order Field Definitions in Co

Posted: Wed Jul 13, 2011 6:33 pm
by M@rtijn
No problem, that's why we are here ;D

The first piece of code will show all the customfields, even if the value is zero (or in your case unchecked).
So I suggest removing that bit.

You say you get errors? Can you post them here?

Re: [Solved] Is it possible to order Field Definitions in Co

Posted: Tue Aug 09, 2011 6:12 pm
by ACDS
Hi Martijn,

I have not had time to further work on this until now. I think the problem I have is that my custom fields contains a number of words e.g. General disaster risk reduction...

thus this code seems wrong:

Code: Select all

{if $entry->customfieldsbyname.General disaster risk reduction ne ''}
{$entry->customfieldsbyname.General disaster risk reduction}
{/if}


This provides the following error on the front end:

Code: Select all

Parse error: syntax error, unexpected T_STRING in /usr/www/users/acds/tmp/templates_c/CompanyDirectory^%%2B^2B8^2B838308%%module_db_tpl%3ACompanyDirectory%3Bdetail_Sample.php on line 56

Re: [Solved] Is it possible to order Field Definitions in Co

Posted: Tue Aug 09, 2011 6:26 pm
by ACDS
Hi Martijn,

I have not had time to further work on this until now. I think the problem I have is that my custom fields contains a number of words e.g. General disaster risk reduction...

thus this code seems wrong:

Code: Select all

{if $entry->customfieldsbyname.General disaster risk reduction ne ''}
{$entry->customfieldsbyname.General disaster risk reduction}
{/if}


This provides the following error on the front end:

Code: Select all

Parse error: syntax error, unexpected T_STRING in /usr/www/users/acds/tmp/templates_c/CompanyDirectory^%%2B^2B8^2B838308%%module_db_tpl%3ACompanyDirectory%3Bdetail_Sample.php on line 56

Re: [Solved] Is it possible to order Field Definitions in Co

Posted: Wed Aug 10, 2011 12:00 pm
by M@rtijn
Yes, the spaces terminate the call.

Just use a single word for your custom fields or underscore the spaces.

If you really want it to show 'General disaster risk reduction' you could make a custom template file (search for 'module_custom') or edit the labels in the lang file.

Re: [Solved] Is it possible to order Field Definitions in Co

Posted: Mon Mar 12, 2012 10:52 am
by Tetsuo
M@rtijn wrote:Yes, the spaces terminate the call.

Just use a single word for your custom fields or underscore the spaces.
Underscoring / removing the spaces stops the error, but it doesn't call the entry.

Re: [Solved] Is it possible to order Field Definitions in Co

Posted: Mon Mar 12, 2012 10:55 am
by calguy1000
This should work:

Code: Select all

{assign var='tmp' value='My field name with spaces in it'}
{$entry->customfieldsbyname.$tmp->value}
Please read the smarty documentation... you will find alot of useful information there... including how to handle array keys with spaces in them.

Re: [Solved] Is it possible to order Field Definitions in Co

Posted: Mon Mar 12, 2012 11:07 am
by Tetsuo
Thanks, but that still doesn't output anything, unless I have missed something more obvious:

Code: Select all

{assign var='tmp' value='Address Line 3'}
{if $entry->customfieldsbyname.$tmp->value ne ''}
<h3>Address Line 3:</h3>
<p>{$entry->customfieldsbyname.$tmp->value}</p>
{/if}