Page 1 of 1
[SOLVED] Company directory extra fields do not work in template?
Posted: Thu Sep 30, 2010 5:13 am
by kittymcooper
Maybe I am misreading the instructions that I saw here
http://wiki.cmsmadesimple.org/index.php/User_Handbook/Admin_Panel/Extensions/CompanyDirectory
it says to access the extra fields in a template use:
{$entry->customfieldsbyname.yourcustomfieldname}
So I defined a field called firstname and tried
{$entry->customfieldsbyname.firstname}
but it is not pulling in the first names, what am I doing wrong?
site is here:
http://nmrid.org/index.php?page=directory-of-interpreters
Re: Company directory extra fields do not work in template?
Posted: Thu Sep 30, 2010 11:42 am
by jmcgin51
did you first use a foreach statement to setup the $entry array?
Re: Company directory extra fields do not work in template?
Posted: Thu Sep 30, 2010 11:56 am
by uniqu3
Did you name your field firstname or Firstname?
Note that it is case sensitive, so this could be your problem.
Re: Company directory extra fields do not work in template?
Posted: Fri Oct 01, 2010 2:50 am
by kittymcooper
Thanks for the ideas but the field is definitely called firstname and of course I have a foreach. Here is the code, the other non-custom fields come out fine:
{foreach from=$items item=entry}
{$entry->company_name|capitalize}, {$entry->customfieldsbyname.firstname}
{$entry->address|capitalize}
{if $entry->contact_email ne ''}
{assign var="mail" value=$entry->contact_email}
{mailto address="$mail" text="" encode="javascript_charcode"}
{/if}
{/foreach}
Re: Company directory extra fields do not work in template?
Posted: Fri Oct 01, 2010 3:11 am
by jmcgin51
just for fun, try taking out the foreach statement...
I have similar code working on one of my sites, and there is no foreach enclosing the {$entry->whatever} variables.
Re: Company directory extra fields do not work in template?
Posted: Fri Oct 01, 2010 3:50 am
by kittymcooper
interesting idea but removing the foreach did not work so I put it back
[SOLVED] Re: Company directory extra fields do not work in template?
Posted: Wed Oct 06, 2010 12:24 am
by kittymcooper
This was really silly. My user had not checked the public box in the custom field definition so it was not appearing.
I solved it by looking at $entry within my loop in my template using the following code to see what was in that object for each item (did view source to see the results as it is within html comments cuz on a live site):
saw nothing and went looking at the definition more carefully ...
hope this helps someone else
Kitty
Re: [SOLVED] Company directory extra fields do not work in template?
Posted: Wed Oct 06, 2010 1:06 am
by jmcgin51
hehe, duh... it's always the simple things, right? thanks for coming back and letting us know!