Showing only a specific Album in WPG2 V3 ?

ramind

Joined: 2007-04-09
Posts: 11
Posted: Tue, 2007-12-18 10:08

I upgraded from V2 to V3 and the feature which I am missing is the ability to display the items from just ONE Album (plus sub-albums) in the Wordpress sidebar widget, as this was possible with V2.

Is there any way for me to do this, or is this feature planned for re-introduction in a future version of the plug-in ?

I use WPG2 V3.0.2, WP V2.3.1, Gallery2 V2.3.3

Thanks for any hints.

 
ozgreg
ozgreg's picture

Joined: 2003-10-18
Posts: 1378
Posted: Thu, 2007-12-20 01:31

Ramind,

The feature is still around if you called the function directly, however as you have noted the widgets do not support this. We do not have any plans to add this back in as the entire imageblock functionality is slated for redevelopment to an internal function in WPG2 3.1 (Rather than using Gallery2 imageblock) to give us greater functionality in future releases..

____________________________________
Wordpress / Gallery2 (WPG2) Plugin, , WPG2 Documentation, WPG2 Demo

 
travelvice
travelvice's picture

Joined: 2005-07-16
Posts: 112
Posted: Mon, 2008-02-18 16:18

Just thought that I'd chime in and say I'd be a fan of this feature as well.

...though I'm not sure how to call this function directly.
Documentation says that <?php print g2_sidebarimageblock(id); ?> only displays the album highlight image, and the grid doesn't seem to have a specific album variable (<?php print g2_sidebargridblock(blocktype, number_of_images, blockmaximgsize, blocktitle); ?>).

What's necessary to create a small sidebar grid of a specific album?

 
ozgreg
ozgreg's picture

Joined: 2003-10-18
Posts: 1378
Posted: Mon, 2008-02-18 21:55

travelvice,

Unfortunately you cannot, as you have found the grid was only coded to support a very limited subset of the G2 imageblock functions and specificID was not one of them..

Your point raises an interesting thought however, I had forgotten about the Random Highlight Module in Gallery2, it could be possible to code the sidebar block (<?php print g2_sidebarimageblock(id); ?>) to point to the ID of the album and then to use the Gallery2 random Highlight module to change the highlight thus giving the appearing of a random photo for a specific album.

Either way, on our development plans we are going to move away from the G2 imageblock function to our own internal function so we can create more flexible random blocks..

____________________________________
Wordpress / Gallery2 (WPG2) Plugin, , WPG2 Documentation, WPG2 Demo

 
travelvice
travelvice's picture

Joined: 2005-07-16
Posts: 112
Posted: Mon, 2008-02-18 22:02

Thanks for the thoughts Ozgreg,

Interestingly enough, I came across this fellow's page:

http://drewd.com/2006/11/28/wpg2-sidebar-block-recent-or-random-images-from-specific-album/

Quote:
WPG2 Sidebar Block: Recent or Random Images from Specific Album

I do not understand why WPG2 does not already support this feature. How hard can this be? You can include one random image from a specific album or all the most recent images from the entire gallery but not a selection of random images from one gallery. Why not take the next logical step?

In g2embed.php, I copied the function g2_sidebargridblock and renamed it g2_sidebargridblock_specific. I added a g2_itemid input parameter and copied three lines of code from g2_sidebarimageblock into the new function, even removing an unnecessary line:

if ( $g2itemid ) {
$blockoptions['itemId'] = $g2itemid;
}

Now, I call the new function from within my WordPress sidebar.php like so:

print g2_sidebargridblock_specific(1234);

The number corresponds to the itemId of the album as found in Gallery2. What astounding programming I have accomplished!

I must admit that my current implementation is not incredibly robust. If no parameter is passed with the g2_sidebargridblock_specific call, recent or random images will be displayed without regard for album. Fine, great. If, however, an invalid itemId is specified, the function will dump a parameter array and output an error. Also, if an itemId for a specific image is given, rather than that of an album, nothing will be displayed at all.

I hope to add some error checking sometime soon but am happy enough with my current result. Configuring this function through the WPG2 control panel would also be convenient. Whatever: I can manage to edit a WordPress plugin PHP file so I hope I can correctly specify a itemId.
Does anyone know if there is an existing function in WPG2 that accomplishes this functionality? Is there a better way to do the same? I would love to hear about it.

copy g2_sidebargridblock (in its entirety) and then add the referenced bit from g2_sidebarimageblock. So, again, copy the g2sidebargridblock function completely and rename it and add an input parameter:

function g2_sidebargridblock_specific( $g2itemid=”", $g2blocktype=”", $g2blockelements=”", $g2blockmaximgsize=”", $g2blocktitle=”" )

Then, replace this:

if ($g2_option[’g2_validated’] == “Yes”) {

// Do we have configuration?
if ( $g2_option[’g2_sidebarblockstype’] || $g2blocktype !=”" ) {
// if no option was passed, set to setting in options
if ( $g2blocktype == “” ) {
$g2blocktype = $g2_option[’g2_sidebarblockstype’];
}

With this:

if ($g2_option[’g2_validated’] == “Yes”) {

// Do we have configuration?

/************ BEGIN NEW CODE ************/

if ( $g2_option[’g2_sidebarblockstype’] || $g2itemid !=”" ) {

// Assign itemID
$blockoptions[’itemId’] = $g2itemid;

/************ END NEW CODE ************/

// if no option was passed, set to setting in options
if ( $g2blocktype == “” ) {
$g2blocktype = $g2_option[’g2_sidebarblockstype’];
}

 
ozgreg
ozgreg's picture

Joined: 2003-10-18
Posts: 1378
Posted: Tue, 2008-02-19 02:37

Actually you could do it much simpler than that, by adding the specific id support back from the sidebar function however you would want to support multiple ID's (one per image grid) to make it all work..

____________________________________
Wordpress / Gallery2 (WPG2) Plugin, , WPG2 Documentation, WPG2 Demo