• twitter image
  • facebook image
  • youtube image
  • linkedin image
Language: CMS Made Simple Czech CMS Made Simple France CMS Made Simple Spain CMS Made Simple Hungary CMS Made Simple Russia CMS Made Simple Netherlands

All times are UTC




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Displaying custom fields in Products module
PostPosted: Sat Mar 06, 2010 8:17 pm 
Offline
New Member

Joined: Sun Sep 13, 2009 12:22 pm
Posts: 3
I used the Products module for a projects page (had it in 'News' first, but I ran into a few dead ends with that one) and I'm using a fair bit of custom fields. It should be simple to use those custom fields in any of the templates provided, but... I can't seem to figure it out.

In the default summary template it says:
Quote:
   {*
     the summary template has access to custom fields via the $entry->fields hash
     and to categories via the $entry->categories array of objects.  Also
     attribute information is available via $entry->attributes.
     you should use the get_template_vars and the print_r modifier to see
     what is available
    *}


I've searched extensively for something on the $entry->fields hash, but no luck.

It seems to me the custom fields are in an array within an array, so after a bit of effort and copy-pasting I came up with:

{foreach from=$entry->fields key='name' item='field'}
{if $field->name == 'summary'}
   {$field->value}

  {/if}
{if $field->name == 'city'}
   {$field->value}
  {/if}
{/foreach}


That works, but it also doesn't seem very efficient.
Is there a shorter/better/more effective way of displaying those custom fields?

Thanks,

Peter.


Top
 Profile  
 
 Post subject: Re: Displaying custom fields in Products module
PostPosted: Sun Mar 07, 2010 7:56 am 
Offline
Forum Members
Forum Members
User avatar

Joined: Wed Apr 01, 2009 6:03 pm
Posts: 147
Location: Plzen, CZ
Hi, you can use this:
Code:
{$entry->fields.name_of_field->value}


Top
 Profile  
 
 Post subject: Re: Displaying custom fields in Products module
PostPosted: Wed Mar 10, 2010 3:29 pm 
Offline
New Member

Joined: Sun Sep 13, 2009 12:22 pm
Posts: 3
Thanks osxfil...

I haven't had the time to look into it as far as I would have wished, but the code suggested doesn't get rid of the foreach loop needed to find stuff within the array right? Anyway, I couldn't get it to work.

In the mean time I found:
http://www.smarty.net/manual/en/languag ... iables.php
which should prove helpful.

(just updating this thread so it might be of help to someone in the future (and until I can add 'SOLVED' to the title))


Top
 Profile  
 
 Post subject: Re: Displaying custom fields in Products module
PostPosted: Fri Apr 30, 2010 9:15 am 
Offline
Forum Members
Forum Members

Joined: Thu Sep 04, 2008 3:49 am
Posts: 84
Thanks so much osxfil, your post was exactly what I was looking for!

{$entry->fields.name_of_field->value}

Just to augment the info, in the case of images:
{$entry->fields.name_of_field->value} is the filename for the main image
{$entry->fields.name_of_field->thumbnail} is the filename for the thumbnail
{$entry->fields.name_of_field->preview} is the filename for the preview image

klontjes - No foreach loop needed, perhaps you were using the wrong field name? name_of_field corresponds with the alpha numeric name you set for each field, not the prompt.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC


Who is online

Users browsing this forum: eddyndm


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Arvixe - A CMSMS Partner