CustomFields

uncool

Joined: 2005-09-08
Posts: 20
Posted: Thu, 2005-09-08 02:53

Hi,

I'm a bit new to gallery, but once I saw gallery2 I knew it was what i needed. However, I'm come across a snafo. I love being able to add custom fields to pictures/albums - but I need to be able to control them. When they are displayed and how they are displayed. How do I access the various custom fields within the templates? I used the smarty debug console to get a listing of the available tags as was suggested in the documentation, but I can't seem to understand it. There is $theme.params.albumBlocks.customfield and $theme.params.photoBlocks.customfield but there is nothing there. I have also seen $theme.children.itemSummaries.customfield - which is where I see my custom fields, but all the fields seem to be in this one line. How can I get access to each individual custom field?

Great work and thanks in advance for the help

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Thu, 2005-09-08 03:41

custom field site admin (or edit album / custom fields) lets you decide which custom fields are displayed as summary info and which in the custom fields block. do you need some additional control?

 
uncool

Joined: 2005-09-08
Posts: 20
Posted: Thu, 2005-09-08 03:53

Yes, I do. I'd like to access each field seperately, mainly for layout and formatting. But i think i might also like to do some processing based on the field, like grouping by a category or something like that. For example, having category name at the top of a page, with its description at the bottom. Also, i think it would be useful to be able to include html in the decription field.

 
shocksll
shocksll's picture

Joined: 2005-06-22
Posts: 352
Posted: Thu, 2005-09-08 11:17
 
uncool

Joined: 2005-09-08
Posts: 20
Posted: Fri, 2005-09-09 14:32

I have read those threads already, and tried going through them again. I just need more information. I put in the g->callback, but I can't seem to get {$theme.item.id} to work. For example, one field is location, so I have tried varations of {$theme.item.location} but to no avail. Also, this might be a smarty issue, but how do you call a field that has spaces in it? I tried playing with some of the code fragments in one of the posts, and got small progress and its very messy - but I can't figure out how to use that to call a field with spaces in it. For example I have a field called "Project Name" and one called "Types of Work Done" - i know i could probably shorten them to "ProjectName" or "TypesOfWorkDone" inside G2, but then the display of that field would look bad for users. Any help?

 
uncool

Joined: 2005-09-08
Posts: 20
Posted: Fri, 2005-09-09 14:41

I forgot to add that i have also tried the debug option turned on, and there doesn't seem to be any additional info added to it by including the g->callback. I do see a reference to customfields.Customfields in the popup, but nothing about whether there are any fields within that. The popup shows those arrays being 0 (for both album and photo)

 
shocksll
shocksll's picture

Joined: 2005-06-22
Posts: 352
Posted: Fri, 2005-09-09 14:47

you access the customfield like this:

$block.customfield.LoadCustomFields.fields.location

Personally I don't know how to access fields with spaces in them in smarty, in a php block you can do it like this

$this->_tpl_vars['block']['customfield']['LoadCustomFields']['fields']['Project Name']

Also, make sure you are calling these after you call the

{g->callback type="customfield.LoadCustomFields" itemId=$theme.item.id} 
 
shocksll
shocksll's picture

Joined: 2005-06-22
Posts: 352
Posted: Fri, 2005-09-09 14:52

another example of something you can do to fix the space problem

{g->callback type="customfield.LoadCustomFields" itemId=$theme.item.id} 
{if !empty($block.customfield.LoadCustomFields.fields)}
{php}
if (isset($this->_tpl_vars['block']['customfield']['LoadCustomFields']['fields']['Project Name']))
	$this->assign('ProjectName', $this->_tpl_vars['block']['customfield']['LoadCustomFields']['fields']['Project Name']);
if (isset($this->_tpl_vars['block']['customfield']['LoadCustomFields']['fields']['Types of Work Done']))
	$this->assign('TypesofWorkDone', $this->_tpl_vars['block']['customfield']['LoadCustomFields']['fields']['Types of Work Done']);
{/php}
{/if}

This means that you will now have two variables

$ProjectName

and

$TypesofWorkDone

That you can use in the smarty. There's probably a better way but I don't know it.