I'm using the advanced profile module (http://drupal.org/project/advanced_profile) -- not the latest "kit" version, but the older one, as I'm still using Panels 1 -- and I'm attempting to integrate the grid block that is bundled with the module.
Essentially I'm adding the following code to a node-uprofile.tpl.php file:
<div id="user-gallery">
<h3>My Gallery:</h3>
<?php
if (_gallery_init(TRUE)) {
require_once(drupal_get_path('module', 'gallery') .'/gallery_user.inc');
if ($link = gallery_user_useralbum(strval($profileuser->uid))) {
$gblock = module_invoke('gallery', 'block', 'view', 'grid-0');
$link2gallery = l(t('View all available images'), $link);
$output = $gblock['content']."<BR><center>".$link2gallery."</center>";
}
else {
if (strval($profileuser->uid) == strval($user->uid)) {
$link = "/portal/gallery";
$output = l(t('add to or edit your gallery'), $link);
}
else {
$output = t('I\'ve not submitted any pictures yet, sorry.');
}
}
print $output;
}
?>
</div>
Basically it checks to see if the user/owner of the profile being viewed has a gallery, and if so, I'm using module_invoke to build the 'grid block' block from the gallery module installation.
The problem I have is this: if I leave the "Album or Item ID" value blank in the block setup, any member images will be displayed on the profile page... but I should only be seeing images belonging to the person whose profile I am viewing. If I set the "Album or Item ID" to "user" then it will attempt to show my images in someone else's profile. All makes sense for traditional use of this block.
However, seeing as I'm using the module_invoke call, is there some way to specify a UID variable? I tried $gblock = module_invoke('gallery', 'block', 'view', 'grid-0', 'user:1'); but nothing changed. I took a look at the block code from the gallery_profile.module file but couldn't figure out how I could edit it properly in order to use that code within the node-uprofile.tpl.php file.
Alternatively, I was going to try to create a new view and use views_build_view but I could not find a way to access gallery-specific items through views.
Any suggestions (or solutions!) are appreciated. :)
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | custom_gallery_block.txt | 1.83 KB | lismail |
| #1 | gallery_block.php_.txt | 1.5 KB | lismail |
Comments
Comment #1
lismail commentedHi,
I don't know if you have solve your issue, but try this code, although you have to rely on Gallery Profile module for UI.
In my case, I create a block, so I can use it anywhere (as block or as panel)
Thanks
Lucky I. Ismail
Comment #2
lismail commentedHi,
Please use this attachment to advance profile. It has better code than previous (can check if gallery module is installed).
Comment #3
profix898 commentedThe solution posted in #2 is certainly better: You shouldnt use
module_invoke('gallery', 'block', ...to get a rendered block, but gallery_get_block() function instead. However, if you get rid of all thosevariable_get('gallery_user_profile_...you dont need GalleryProfile to get this working. All you need is gallery_user_useralbum() and gallery_get_block() which are both available with just the main Gallery module.Untested snippet, but you should get the idea. Most parameters are optional and can be omitted (see G2 codex).
Comment #4
plan9 commentedThis code is exactly what I've been looking for. Thanks lismail, profix898.
Only lismail's #2 code works for me - but I'd like to use your leaner code profix898 as I don't have Gallery Profile installed - being stuck on stuck on 5.x, but when I try it I always get 'Album not available' returned for every profile.
I'm using the current version of Michelle's wonderful APK.
Comment #5
profix898 commented@plan9: my code shows a $uid variable which is not necessarily available in your template, try to replace that with '$profileuser->uid' or sth. as suggest by BradM, otherwise the code should work just fine.
Comment #6
plan9 commentedThanks for the advice profix898
I tried both substitutions but now get the error: Parse error: syntax error, unexpected T_REQUIRE_ONCE in /var/www/vhosts/home/httpdocs/includes/common.inc(1366) : eval()'d code on line 3
Previously there were no errors - although no images either.
Comment #7
plan9 commentedComment #8
lismail commented@plan9:
I am not sure, but seems like you have issue with this line:
require_once(drupal_get_path('module', 'gallery') .'/gallery_user.inc');
Eventhough using drupal_get_path() is recommended, have you tried to point it directly to the file? For example to /var/www/vhosts/home/httpdocs/sites/modules/gallery/gallery_user.inc?
Comment #9
lismail commentedOr, maybe test it by copy/paste the gallery_user.inc content to replace require_once()?
(I know this is a stupid approach but sometime quite effective in test environment)
Cheers,
Comment #10
pjek commentedI have tried both blocks mentioned above in drupal 6.
But at approach in comment #2, I only get to the profile owners album in the block, no images, and at approach as mentioned in comment #3 I only get a link to the user browsing the album, no images too
For my simple logic it could be a lot easier if there was just as mentioned in the Original Post a way to have an unique Album ID for the profile owner? somethin like useralbum or so, I have no clue where to start looking. Because in that case I could simply include a standard Gallery Block into the user profile panel.
I am using Drupal 6, APK latest version and Panels 2 of course.
I am also not sure wheter it is ok to change the version of this tread like this, pardon me if it is not allowed.
Comment #11
lismail commented@pjek
have you installed Gallery Profile module along with above suggestions?
Comment #12
pjek commented@comment 11:
Yes I do have the gallery profile module installed indeed.
Comment #13
pjek commentedactually i just tried the solution in comment #3 and while it get me at least the thumbnails, so I am one step further, but it get the album of the user viwing the page rather than the profile owners albums, and also the link to the visiting user album, rather that the profile owner album
Comment #14
lismail commented@pjek
Interesting. Please try by adding this line before if (_gallery_init(TRUE)) {
$uid = arg(1);
Also try two scenarios, (1) create block with the code and add this block to APK + Panel, (2) add the code directly to APK + Panel.
Comment #15
autoberater commentedI like to show the gallery2-profile in advanced-profile too.
But the way creating a block with the code and add this block to APK + Panel does not work, I only get the code back even though using full html code.
So can you please tell me, where I have to insert the node-uprofile.tpl.php file.
I'm using the latest modules of APK and Panels.
Thanks!
Comment #16
abaddon commented@#15 please try using full php code :-) thats php not html, for the php input filter try to enable the core "php" module, also take care if you touch its permissions not to enable it for anonymous users! defaults are secure and should work for you
p.s. ive tried both methods - block and custom panel code and both work fine for me, i get the link to the album and a few random pictures displayed from the user's album
p.p.s
here's my own version of the code above
basically the same, but using the private function that code was copied from, double check when you upgrade the gallery module, it will also filter the ugly title you might get like "Random Images"..
you set the settings here /admin/user/gallery/settings/profile in the Useralbum Settings fieldset
im using this as custom content for the user panel (Add Content > New custom content, PHP input filter selected..)