[SOLVED] How do I retrieve custom fields?

MichelleC

Joined: 2005-04-16
Posts: 42
Posted: Wed, 2005-11-16 00:48

I have added some custom fields to my photos and would now like to use them in my theme. Is there a function that will put them into an array for me? I was going to try and adapt the code in this thread even though it's not quite what I want, but the code doesn't work at all. It's an old thread, so I guess something has changed.

Anyone know how to do it with the latest G2?

Thanks,

Michelle

 
draco2002

Joined: 2003-04-28
Posts: 70
Posted: Wed, 2006-09-27 16:14

Might want to try something like this (its what i use in the siriux theme)

Quote:
{if !empty($block.customfield.LoadCustomFields.fields)}
{foreach from=$block.customfield.LoadCustomFields.fields key=field item=value}
{$field}: {$value}<br/>
{/foreach}
{/if}

|| G1 + G2 Hosting | Custom Theming | Donate to Gallery ||

 
MichelleC

Joined: 2005-04-16
Posts: 42
Posted: Wed, 2005-11-16 04:09

I just realized the problem. I was in the process of typing that your code was pretty much like the other thread that wasn't working when I realized that's because that code is intended for the photo page where item.id makes sense. I needed to change it to child.id. Doh!

Thanks,

Michelle

 
genu

Joined: 2006-04-24
Posts: 9
Posted: Wed, 2006-09-27 16:07

how do you adapt that code to work on the album page, so it show the custom fields on the next to each thumbnail on the album page?

 
genu

Joined: 2006-04-24
Posts: 9
Posted: Wed, 2006-09-27 16:43

I tried that, but it shows the custom fields, but loads them from the whole album, so all the items have the same information for the fields, it doesnt load the individual item fields.

 
draco2002

Joined: 2003-04-28
Posts: 70
Posted: Wed, 2006-09-27 16:49

Yeah sorry about that, got your comment. When i saw mine i had an un-needed quote tag in it so i edited it. Then the comment dropped to the bottom.

Can't test it till i get home, but i'll see what i can do about getting you an updated peice of code.

-Draco

||Custom Theming | Custom Gallery /Drupal Hosting | Donate to Gallery ||

 
draco2002

Joined: 2003-04-28
Posts: 70
Posted: Wed, 2006-10-11 02:27

Sorry for the delay.

This code is more proof of concept than production code, but it will get you started, Can't give you all the answers ;)

theme.inc in showAlbumPage under where you declare $theme

	foreach ($theme['children'] as $i => $child) {
		$itemid = $child['thumbnail']['derivativeSourceId'];
		list ($ret, $results) = GalleryCoreApi::loadEntitiesById($itemid);
    list ($ret, $fields) = CustomFieldHelper::fetchFieldValues(array($results), 'detail');
	  $theme['children'][$i]['customFields'] = ($fields);
	}

page.tpl

{if !empty($child.customFields)}
  {foreach from=$child.customFields[$child.id] key=field item=value}
    {$value}<br/>
   {/foreach}
{/if}

||Custom Theming | Custom Gallery /Drupal Hosting | Donate to Gallery ||