[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 |
|

Posts: 70
Might want to try something like this (its what i use in the siriux theme)
|| G1 + G2 Hosting | Custom Theming | Donate to Gallery ||
Posts: 42
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
Posts: 9
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?
Posts: 9
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.
Posts: 70
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 ||
Posts: 70
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 ||