Custom Fields: same field show up for: Common, Album, and Photo Fields?

whodah
whodah's picture

Joined: 2003-05-17
Posts: 96
Posted: Sat, 2005-10-08 18:31

Hello!

I did search, but to no avail...

For G2.0, I'd like to have the same Custom Field show up in the Common, Album, and Photo Fields.

I.e. I only have to fill out the Common Field 'Coral Name' once and it shows up on both the album and the photo pages.

Is this possible?

Thanks!


Gallery version (not just "2"): 2.0

G1 installs x 9
G2 installs x 3

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Sat, 2005-10-08 21:15

you set field values per item. item = either albums or dataitems (photo, movie, ...).
so a custom field value is a per item attribute.
if you edit an album and assign a value to a custom field, it's an attribute of this album item.

you can edit the photo.tpl to also show the custom field values of the parent album. is that what you want?

 
whodah
whodah's picture

Joined: 2003-05-17
Posts: 96
Posted: Mon, 2005-10-24 23:34

ya, that'd work great! :D

i see this bit of code in photo.tpl and album.tpl

        {foreach from=$theme.params.photoBlocks item=block}
          {g->block type=$block.0 params=$block.1}
        {/foreach}

any hints on what that $block.1's valid values are? ;)

i can print out block.0, but block.1 appears to be another array.

thx!!

9 x G1
3 x G2

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Mon, 2005-10-24 23:52

the only related docs we have right now:

http://codex.gallery2.org/index.php/Gallery2:Tpl_Reference#Blocks

maybe i could answer a more specific question...

 
whodah
whodah's picture

Joined: 2003-05-17
Posts: 96
Posted: Tue, 2005-10-25 00:23

heya!

thx for the link!

my more specific question would be: would you happen to know what the $block.1 value is for:

  1. photo.tpl
  2. album.tpl

i'm hoping to do something like this in local/photo.tpl (as per your suggestion - if i interpreted it correctly, ha!):

{* photo custom fields *}
        {foreach from=$theme.params.photoBlocks item=block}
          {g->block type=$block.0 params=$block.1}
        {/foreach}


{* album custom fields *}
        {foreach from=$theme.params.photoBlocks item=block}
          {g->block type=$block.0 params="**value of $block.1 when called from album.tpl**"}
        {/foreach}

thx! :D

9 x G1
3 x G2

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Tue, 2005-10-25 03:53

well, each block accepts some parameters. these parameters are different for each block.
see the template reference link from before for some examples.

 
whodah
whodah's picture

Joined: 2003-05-17
Posts: 96
Posted: Tue, 2005-10-25 21:01

ok, so i see the help you referenced on the link above reguarding blocks:

Quote:
# customfield.CustomFields [item=..]

* Show 'detail' custom fields for given item (defaults to $theme.item)

and when viewing a photo, in photo.tpl, i can call the photo's custom fields:

{g->block type="customfield.CustomFields"}

but how can i pass the album's info to the block call from within the photo template?

i can do this and it 'works' for the photo:

{g->block type="customfield.CustomFields" item=$block.customfield.LoadCustomFields.fields}

but i'm not so sure it's 'working' so much as just going back to the default...

man, it seems like it would be easy, but i'm totally lost here.

i've been trying things like:

{g->block type=customfield.CustomFields item=album}
{g->block type=customfield.CustomFields item=$this.album}

but just cannot find the answer!

any other clues? :(

9 x G1
3 x G2

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Tue, 2005-10-25 21:38

see modules/customfield/Callbacks.inc
there you see what params are expected.

also see modules/customfield/templates/blocks/CustomFields.tpl

there you see the call for callbacks
{g->callback type="customfield.LoadCustomFields" itemId=$item.id|default:$theme.item.id}

the same pattern for all blocks.

- 'type' is always required.
- all additional parameters that you provide are automatically available in modules/moduleName/templates/blocks/blockName.tpl
- in blockName.tpl, most blocks call modules/moduleName/Callbacks.inc which gets its params from the g->callback call and not from your g->block call.

if you think the docs on codex need some clarification etc., i'd appreciate if you could update them.
thanks!