I am attempting to develop a personal portfolio site in which users submit their work, including anything from flash movies to images, etc, into their albums, and it is then viewable on their user page. I have been able to get the user albums for each user using "gallery2", but all i can manage is to place a ling to the users gallery on their user page, rather than display images from the gallery itself.

I know that the following code in my template.php creates the link:

<?php
        global $user;
        $galleryprofile=gallery_view_user($user);
        print $galleryprofile['Gallery2']['gallery_view_user_album']['value'];
        ?>

I have tried playing around with this code to make it display the content of the page/node (or whatever) it links to but have had no success.

the following is what my user profile looks like (follow the link):
http://farm3.static.flickr.com/2340/1497822682_1ad35469d8_b.jpg

PS. once I have got the user pages sorted out, I want to create a browse page, which has different cegories which can be searched/browsed, and all the images are displayed ther no matter what not the albums, then when you click on the image, it will take you to that image and you can comment on it or rate it, and from there there is a link to the user which uploaded/created the image. (but first I want to sort out the userpage bit)

my main source of inspiration is www.deviantart.com

If you need any more of my codes or any other information, please ask and I will definitely post it, because I really want this to work.

not sure if this could help in any way, but the following post has a whole lot of code that is related to playing around with gallery2 links. It is definitely not what I need, but it may help any one who wants to help me. :)

http://drupal.org/node/155195

Comments

profix898’s picture

With the 5.x-1.x series it requires much more code to fetch images from a useralbum. You will need a modified version of gallery_view_user() to return the album id. You can then fetch images from that album by using the getImageBlock() method of G2. I can send you assembled code for this purpose if you wish.

However as your site is not yet productive I suggest that you update to the 5.x-2.x-dev version, where all this is basically a one liner.

odonja09’s picture

Version: 5.x-1.0 » 5.x-2.x-dev

thank you for that information, I had a feeling it would take quite a bit of coding. luckily for me, I just made a mistake in the version selection for this issue page and I do actually have the latest "drupal 5.2", so if I could follow up on your offer to send me the coding/information i need for 5.2 (where it is all basically a one liner) it would be very much appreciated.

I thank you in advance for the coding/information, and i apologise profusely for mixing up the version numbers on this post.
:)

profix898’s picture

I originally though of this: Use $item_id = gallery_user_useralbum($uid, FALSE); to get the itemId of the useralbum and then use getImageBlock() to fetch the actual images. However this required some extra code to format the result.

But now I have committed a patch which reorganizes and simplifies the block code while making it more generic at the same time. I've also added a gallery_get_block() function which greatly eases the task for you (and for other purposes) :)

Here is the code you need to include a user gallery on your pages (as image or grid block):

// Image block (with random image from useralbum of Drupal uid 1)
$params = array(
  'blocks' => 'randomImage',
  'itemId' => 'user:1'
);
$block = gallery_get_block($params);
print $block['content'];

// Grid block (4 random images in 2 columns from useralbum of Drupal uid 8)
$params = array(
  'blocks' => implode('|', array_fill(0, 4, 'randomImage')),
  'itemId' => 'user:8'
);
$block = gallery_get_block($params, 2);
print $block['content'];

The examples above are very basic, but you can pass in every parameter that getImageBlock() takes., e.g. you can specify which attributes to show (title, date, ...), what type of images to show (randomImage, recentImage, ...), and so on ... You may also pass a css class name as third parameter to gallery_get_block(), so that you can customize the default layout/design.

profix898’s picture

I just released beta4 including all required changes. So best get it ;)

odonja09’s picture

thanks for the coding, this really helps. :)

when you say, you have brought out beta 4, and it has all the changes required, does that mean it has an easier way to do the user gallerys on user pages? or is it just better because it is improved (i will get it anyway, but that info would help)

profix898’s picture

Whats the difference between 'has an easier way' and 'it is improved'? Sounds alike to me!? However beta4 includes all changes required to use the code in #3 (gallery_get_block() was introduced in beta4). It wont get easier than this for D5/G2.2.

profix898’s picture

Status: Active » Closed (fixed)