Adding options to the ImageBlock module.

gaynormcc
gaynormcc's picture

Joined: 2003-09-05
Posts: 426
Posted: Thu, 2006-02-09 02:29

As I had asked in http://gallery.menalto.com/node/44027:-
I am wanting to add images with links/URLs/text below them into the sidebar in G2.”

ckdake suggested using the image block module and :-
“If you need it to be configurable per album/item, You'd need to write a module.”

So I am transferring this to Module forum.

(A) One of the things I want to do is designate a specific image (as an image block) The Link or text would be its title/caption brought with it.
(B) I'd also like to be able to have an image block being a random image from within a specific sub-album. I’d like to be able to set it in “Edit Album/theme” so perhaps it could be called “Current Album Random Image”

Presumably I need to add Adaptations of the line
'randomImage' => $gallery->i18n('Random image'),
in gallery2/modules/imageblock/templates/blocks/blocks.inc

eg 'specificImage' => $gallery->i18n('Specific Image'),
and ' CurrentAlbumRandomImage ' => $gallery->i18n('Current Album Random image'),

# But how and where do I define the "Specific image" and
'Current Album Random Image' ?

Valiant seems to answer this in his reply to someone else in
http://gallery.menalto.com/node/43500 :-

“you'll have to modify the imageblock module, maybe
modules/imageblock/templates/blocks/ImageBlock.tpl
just put the description somewhere in the template with:
{$block.item.description} “

Could you please give me an example of the line required ?
eg what would I write to get the “current album random image”

Gaynor (Learning heaps with your help)

 
gaynormcc
gaynormcc's picture

Joined: 2003-09-05
Posts: 426
Posted: Thu, 2006-02-09 03:31

Heavens, I am thinking on my feet here.

What I really want is even more than above.
I'd like the sidebar to have three imageblocks in it each one giving random images from a different specified album

So the line adaptation would be

'Album_01RandomImage ' => $gallery->i18n('Album_01 Random image'),

Presumably this would generate a dropdown album tree in the Edit Album/Theme Imageblock selection.
and the Specific Image line generate a corresponding dropdown or a link to an index page similar to what Nick (gamecat) is working on in http://gallery.menalto.com/node/44193

Golly this does get complicated doesn't it.
But Site admin/imageblock does already have "SpecificItem" mentioned and referred to as available for external blocks. So presumably code for it is somewhere.

Gaynor

 
ckdake
ckdake's picture

Joined: 2004-02-18
Posts: 2258
Posted: Thu, 2006-02-09 05:57

Here's what you would need to do:

-Get imageblock working returning a specifc album, item, or album and its subalbums, etc
-Add a setting to your new custom theme settings page that allows you to set some number of image blocks
-Add a setting that can be repeated over and over that has a few fields:
-type (random from album, random from album+subalbums, specific, etc)
-itemID (album's id for album options above, item's id for items)

-Modify the theme to check for those settings and call the modified imageblock as needed

 
gaynormcc
gaynormcc's picture

Joined: 2003-09-05
Posts: 426
Posted: Thu, 2006-02-09 07:26

This looks as if it could work Chris, but I can;t work out how to do these steps.

The English is understandable in English.

At present I am having difficulty translating your instructions (in English) into computer language.

Gaynor

 
gaynormcc
gaynormcc's picture

Joined: 2003-09-05
Posts: 426
Posted: Thu, 2006-02-09 11:07

So do you mean:-

In {$block.item.description}
item = ‘randomImageFromAlbum_01 (ID of album01)’
and description = 'Random Image from Album_01'

So I have to adapt {$block.item.description} to
{$block.’randomImageFromAlbum_01 (ID of Album01)’.’Random Image from Album_01’} etc

and adapt
'randomImage' => $gallery->i18n('Random image'), to
‘randomImageFromAlbum_01 (ID of album01)' => $gallery->i18n('Random image from album_01'),
etc

I need to copy the module “imageblock” to a newly created folder called “local” then in gallery2/modules/local/imageblock/templates/blocks/blocks.inc

include
{$block.’specificItem (id for specific Item)’.’Specific Item’},

{$block.’randomImageFromAlbum_01 (ID of album_01)’.’Random Image from Album_01’},

{$block.’randomImage from album_02 (ID of album_02)’.’Random Image from album_02’}

and in the relevant position, add
{‘specificItem (id for specificItem)' => $gallery->i18n(‘Specific Item’),

‘randomImageFromAlbum_01 (ID of album01)' => $gallery->i18n('Random image from album_01'),

‘randomImageFromAlbum_02 (ID of album02)' => $gallery->i18n('Random image from album_02'),
}

Which should then add to the dropdown list in ‘block/ImageBlock’ on the ‘Edit Album/theme’ page

“ ‘Specific Item’, 'Random image from album_01’, and 'Random image from album_02' “

Am I correct?

Gaynor

 
ckdake
ckdake's picture

Joined: 2004-02-18
Posts: 2258
Posted: Thu, 2006-02-09 16:08

Nope. That wouldn't be very flexibile because you would have to modify the code for each album. I'd say you want to add something along the line of:

gallery2/modules/imageblock/classes/ImageBlockHelper.class: ~66

'specificAlbum' => $gallery->il8n('Specific Album'),
'specificItem' => $gallery->il8n('Specific Item')

Then take a look at _getBlockData in that file and add a case for those to and figure out what needs to be done there.

Then, add stuff into gallery2/modules/imageblock/ImageBlockOption.inc to allow an admin to set wether or not to show a specific item as a block, and if so what kind and what id to use.

For now, just try and get a subset of functionality working and you can expand from there (an option in ImageBlockOption for an id, if its blank don't use it, if its not blank, show that id's thumbnail at the bottom of the page)