[Solved] SpecificItem option for ImageBlock within G2

TomPouce25

Joined: 2009-01-28
Posts: 13
Posted: Fri, 2009-01-30 17:47

Hi all,

I would like to have an "editorial pick", a.k.a "image of the month", image in my Gallery 2.3 installation.

The Image Block module is very close to what I'd like to achieve except that I need to choose the image that has to be displayed. I have seen several posts about that (e.g. http://gallery.menalto.com/node/44201) but couldn't find a way to make that work. I am new to Gallery, so please bear with me.

What I did right now is modify the modules/imageblock/templates/blocks/blocks.inc file (bold stands for my additions):

'blocks' => array(
'description' => $gallery->i18n('Image type'),
'type' => 'choice',
'default' => 'randomImage',
'choices' => array(
'randomImage' => $gallery->i18n('Random image'),
'specificItem' => $gallery->i18n('Specific item'),
'recentImage' => $gallery->i18n('Recent image'),
'viewedImage' => $gallery->i18n('Viewed image'),
'randomAlbum' => $gallery->i18n('Random album'),
'recentAlbum' => $gallery->i18n('Recent album'),
'viewedAlbum' => $gallery->i18n('Viewed album'),
'dailyImage' => $gallery->i18n('Daily image'),
'weeklyImage' => $gallery->i18n('Weekly image'),
'monthlyImage' => $gallery->i18n('Monthly image'),
'dailyAlbum' => $gallery->i18n('Daily album'),
'weeklyAlbum' => $gallery->i18n('Weekly album'),
'monthlyAlbum' => $gallery->i18n('Monthly album'))),
'itemId' => array(
'description' => $gallery->i18n('Specific item ID'),
'type' => 'text',
'default' => ''),

'repeatBlock' => array(
'description' => $gallery->i18n('Number of items'),
'type' => 'text',
'default' => '1'),

This allows me to specify the specific item ID I need from the admin interface of the theme. However the "itemId" field gets lost in the way and in the end there is no image in my image block.

Now if I modify modules/imageblock/Callbacks.inc to hardcode the "itemId" (e.g. 151 here), I do get the expected output. That is, My image 151 shows up in the image block.

if (!isset($params['itemId'])) {
$params['itemId'] = '151';
}

$ret = ImageBlockHelper::loadImageBlocks($template, $params);

Could you help me find what I need to change in order to make the whole thing work without having to hardcode the itemId?

Best regards,
Tom

 
TomPouce25

Joined: 2009-01-28
Posts: 13
Posted: Wed, 2009-02-04 12:21

I guess it must have been a cache issue. Since the above patch now works.

I have also added the following lines in modules/imageblock/classes/ImageBlockHelper.class

case 'specificItem':
$title = $module->translate(array('one' => 'Editorial Pick',
'many' => 'Editorial Picks', 'count' => $plural));
break;

Tom