Custom Fields Output

ricardo m
ricardo m's picture

Joined: 2007-01-27
Posts: 2
Posted: Sat, 2007-01-27 14:50

Hi there.
Im'm new to G2 and I'm trying to show data from the custom fields I've created: 'Year', 'Medium' and 'Size' but it just doesn't output anything.
I followed this tutorial

http://codex.gallery2.org/index.php/Gallery2:How_to_display_custom_fields_next_to_thumbnail

and pasted this code next to my thumbnails in album.tpl. I'm using Siriux template.

{* Use the customfield.LoadCustomFields callback to get an array of fields *}
{g->callback type="customfield.LoadCustomFields" itemId=$child.id}
{if !empty($block.customfield.LoadCustomFields.fields.Item)}
<ul>
{foreach from=$block.customfield.LoadCustomFields.fields item=customField}
<li>{$customField}</li>
{/foreach}
</ul>
{/if}

Can anyoine help me? Thanks

---
ricardo m

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Sun, 2007-01-28 01:37

try

{g->callback type="customfield.LoadCustomFields" itemId=$child.id}

<ul>
{foreach from=$block.customfield.LoadCustomFields.fields item=customField}
<li>{$customField}</li>
{/foreach}
</ul>

I guess the empty check is wrong

Dave

_____________________________________________
Blog & G2 || floridave - Gallery Team || G2 Theme Contest!

 
dvfreeman

Joined: 2006-11-17
Posts: 24
Posted: Fri, 2007-02-02 01:19

Dave,

Using the forum guidance, I have been able to cancel out the existing Owner and Date on photo.tpl (due to their limitations) and I have successfully added Custom Fields Owner and Date. However, this information shows up under the photo Comments and is not readily apparent to the viewer.

Is there coding that I can add to photo.tpl so that these custom fields (without the title Custom Fields) shows up under the description (where the Date and Owner fields were originally located)? I would appreciate your help.

Dave Freeman

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Fri, 2007-02-02 04:05

I think I understand your question....
Edit album, theme tab, 'Blocks to show on photo pages' reorder the custome filed block to be above the comment block.

@removing the title of the module edit:
/modules/customfield/templates/blocks/CustomFields.tpl

Dave

_____________________________________________
Blog & G2 || floridave - Gallery Team || G2 Theme Contest!

 
dvfreeman

Joined: 2006-11-17
Posts: 24
Posted: Fri, 2007-02-02 05:20

Dave -

Thanks for the timely reply. Your guidance allowed me to get rid of the title "Custom Fields" and move my custom fields (Date and Owner) above any "Recent Comments" that might be on the photo page. However, rather than residing underneath the photo, I would like to position these custom fields to the right of the photo underneath any description text that might be there. This will make these custom fields more obvious to the viewer.

I assume this means some recoding of one of the files - possibly the photo.tpl file. I have reviewed the forum questions on Custom Fields and most responses relating to repositioning the fields on the photo page aren't sufficiently precise for me to understand what needs to be done. That's the guidance I need. What file needs changing and what coding in that file needs changing? Again, I really appreciate your helping this newbie.

Dave Freeman

 
dvfreeman

Joined: 2006-11-17
Posts: 24
Posted: Sat, 2007-02-03 04:25

Problem Solved!! I didn't research the theme page enough to recognize there were two sections that controlled where custom fields are added to the photo page. Sorry for exercizing the troops.

Dave Freeman

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Sat, 2007-02-03 04:36

glad you got it sorted.
_____________________________________________
Blog & G2 || floridave - Gallery Team || G2 Theme Contest!

 
markdj

Joined: 2008-03-01
Posts: 18
Posted: Sat, 2008-04-19 22:16

Umm, I would really love to know how to move the custom fields to the right of the photo. Any help on this is greatly appreciated. Here's my site currently.

http://www.gerrysfineirishart.com/gallery2/v/noelshaw/afternoon_chat.jpg.html

 
markdj

Joined: 2008-03-01
Posts: 18
Posted: Tue, 2008-04-22 23:30

Please help, I am using the Matrix theme.

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Wed, 2008-04-23 03:20

Edit photo.tpl.
You will have to ad a table or a <div> around the image. Add some text to see where things show up. Once you get that far you can add the custom field.

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
beckett2u

Joined: 2008-08-15
Posts: 13
Posted: Thu, 2009-01-01 18:56

Okay, so I am running Gallery 2 and am using a modified version of the Ebony template.

What I need to be able to do is display the "Custom Field" under each of the photo thumbnails on the album page. I have tried pasting your example code in various pages on the "album.tpl" file with no luck. The closest I got was pasting it into the template specific "modules/core/templates/blocks/local/iteminfo.tpl". Adding it into that file actually placed the item-specific Custom Field code under each of the items, but it didn't strip out the link code that I have in each of them (which works fine in the photo view). I would think displaying this in the Album view would be no problem considering I got it to display in the photo view with the build-in functionality of Gallery2 without modifying code.

Any suggestions would be appreciated, and let me know if you need more info.

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Thu, 2009-01-01 19:40

I don't have the ebony theme but in matrix I add:

{g->callback type="customfield.LoadCustomFields" itemId=$child.id}

<ul>
{foreach from=$block.customfield.LoadCustomFields.fields item=customField}
<li>{$customField}</li>
{/foreach}
</ul>

under

                {if ($child.canContainChildren && $theme.params.showAlbumOwner) ||
                    (!$child.canContainChildren && $theme.params.showImageOwner)}
                {assign var="showOwner" value=true}
                {else}
                {assign var="showOwner" value=false}
                {/if}
                {g->block type="core.ItemInfo"
                          item=$child
                          showDate=true
			  showOwner=$showOwner
                          showSize=true
       		          showViewCount=true
                          showSummaries=true
                          class="giInfo"}

and it works for me.

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
beckett2u

Joined: 2008-08-15
Posts: 13
Posted: Thu, 2009-01-01 20:23

Thanks for getting back to me. I tried adding that to the album.tpl file in the place you indicated and nothing happened. Is it possible that the theme is ignoring this file or do different templates reference things differently? You'd think that it would be a universal application across the board. Any other suggestions?

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Thu, 2009-01-01 21:44

Clear cache?
FAQ: How can I clear cached data?
Do you have any data added to the custom fields?

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
beckett2u

Joined: 2008-08-15
Posts: 13
Posted: Thu, 2009-01-01 22:27

Just tried clearing the template cache and still no go. I do have data in the custom fields, as they display fine in the photo view. Anything else?

Kyle

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Thu, 2009-01-01 23:40

URL?

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
beckett2u

Joined: 2008-08-15
Posts: 13
Posted: Thu, 2009-01-01 23:55

http://fuseboxgraphics.com/gallery/main.php?g2_itemId=61

The "websites" section is the only album I want to use the custom fields for, to display the URL to each live site below each thumbnail, instead of having to go into each item to get to it.

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Fri, 2009-01-02 02:40

Add some text to the same location, does it show up?
change to the matrix theme and change the album.tpl, does it work?

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
beckett2u

Joined: 2008-08-15
Posts: 13
Posted: Fri, 2009-01-02 03:55

Alright, I changed templates and I am seeing an error where I added the code/test text - both with the same results. This is the error:

[Translation error: Array ( [one] => (%d item total) [many] => (%d items total) [count] => [arg1] => ) ]

I left the Matrix theme applied if it helps. I appreciate all your help.

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Fri, 2009-01-02 04:00

Add some text without the code first. Does that work?

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
beckett2u

Joined: 2008-08-15
Posts: 13
Posted: Fri, 2009-01-02 04:11

Added the text with no extra code and still nothing even after emptying the cache again.

 
beckett2u

Joined: 2008-08-15
Posts: 13
Posted: Fri, 2009-01-02 04:12

Hold on a sec....I updated the file from the old template...

 
beckett2u

Joined: 2008-08-15
Posts: 13
Posted: Fri, 2009-01-02 04:20

Okay, so I actually added the code to the Matrix themed album.tpl and that added the custom info to the album page, but it is not turning the code into links like on the individual photo pages. Is there a way to modify the code to have it convert it?

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Fri, 2009-01-02 05:42

So you got it working on the album page?

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
beckett2u

Joined: 2008-08-15
Posts: 13
Posted: Fri, 2009-01-02 05:56

Yes, I got it working in the matrix template, but not the ebony template that I use. There is also the matter of the link code not hyperlinking within the album view (which if I can't get to work properly, then showing the custom field on the album page is useless for my purposes). Any ideas?

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Fri, 2009-01-02 06:05

Sorry I don't know much about the ebony theme. You will have to study the theme, perhaps the author of the theme will see this thread and help you out.

Quote:
There is also the matter of the link code not hyperlinking within the album view

I don't understand. But if is specific the ebony theme, I suspect I will not be able to help much.

Dave

_____________________________________________
Blog & G2 || floridave - Gallery Team

 
beckett2u

Joined: 2008-08-15
Posts: 13
Posted: Fri, 2009-01-02 18:25

Eureka, I've figured it out! This other board topic walked me through what else needed to be added to the code mentioned above to make it parse the hyperlinks properly: http://gallery.menalto.com/node/51080

For my uses with the Ebony theme, I had to add the code to the following: "modules/core/templates/blocks/local/iteminfo.tpl"

The modified code that I had to use is: (I stripped out the list item code, which I didn't need)

{g->callback type="customfield.LoadCustomFields" itemId=$child.id}
{foreach from=$block.customfield.LoadCustomFields.fields|markup item=customField}
{$customField}
{/foreach}

The BBcode that I was already using for my links in the Custom Fields now displays correctly in both the photo view (as it had before) AND on the album view. It is all thanks to the simple change of adding "|markup". I hope this helps other people as much as it did for me.