[SOLVED] Company directory extra fields do not work in template?

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
User avatar
kittymcooper
Forum Members
Forum Members
Posts: 44
Joined: Sat Aug 02, 2008 4:40 am

[SOLVED] Company directory extra fields do not work in template?

Post 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
Last edited by kittymcooper on Wed Oct 06, 2010 12:25 am, edited 1 time in total.
Kitty Munson Cooper, web designer, programmer
jmcgin51
Power Poster
Power Poster
Posts: 1899
Joined: Mon Jun 12, 2006 9:02 pm

Re: Company directory extra fields do not work in template?

Post by jmcgin51 »

did you first use a foreach statement to setup the $entry array?
uniqu3

Re: Company directory extra fields do not work in template?

Post by uniqu3 »

Did you name your field firstname or Firstname?
Note that it is case sensitive, so this could be your problem.
User avatar
kittymcooper
Forum Members
Forum Members
Posts: 44
Joined: Sat Aug 02, 2008 4:40 am

Re: Company directory extra fields do not work in template?

Post 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}
Kitty Munson Cooper, web designer, programmer
jmcgin51
Power Poster
Power Poster
Posts: 1899
Joined: Mon Jun 12, 2006 9:02 pm

Re: Company directory extra fields do not work in template?

Post 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.
User avatar
kittymcooper
Forum Members
Forum Members
Posts: 44
Joined: Sat Aug 02, 2008 4:40 am

Re: Company directory extra fields do not work in template?

Post by kittymcooper »

interesting idea but removing the foreach did not work so I put it back
Kitty Munson Cooper, web designer, programmer
User avatar
kittymcooper
Forum Members
Forum Members
Posts: 44
Joined: Sat Aug 02, 2008 4:40 am

[SOLVED] Re: Company directory extra fields do not work in template?

Post 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
Kitty Munson Cooper, web designer, programmer
jmcgin51
Power Poster
Power Poster
Posts: 1899
Joined: Mon Jun 12, 2006 9:02 pm

Re: [SOLVED] Company directory extra fields do not work in template?

Post by jmcgin51 »

hehe, duh... it's always the simple things, right?  thanks for coming back and letting us know!
Post Reply

Return to “Modules/Add-Ons”