Closed (fixed)
Project:
Gallery
Version:
5.x-1.0
Component:
Miscellaneous
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
28 Jun 2007 at 01:04 UTC
Updated:
12 Nov 2009 at 07:22 UTC
Hello,
has anybody managed to link from an album/photo to the user profil?
I tried to include a link in photo.tpl that points to the user profil. I can't
acces Drupals uid in embedded Gallery.
I know that the externalId/uid is stored in a table called g3_ExternalIdMap,
but how can I acces this table from photo.tpl?
Thanks in advance,
Marco
Comments
Comment #1
profix898 commentedIts quite easy to achieve what you want. Open the theme.inc file of your theme. If you need an additional variable for a photo page, search for the 'showPhotoPage(&$template, $item, $params) { ... }' function. As the $user object of Drupal is a global variable you can easily access it directly (even outside Drupal, e.g. in G2). You can now get and modify all available theme variables using
$theme =& $template->getVariableByReference('theme');. In case you need a new template variable 'drupaluser' containing the Drupal username then you would use the following code:In your .tpl file you can then access the 'drupaluser' variable like any other predefined variable. If you e.g. want to welcome the user with its Drupal username, you would add the following line to your template
Welcome {$theme.drupaluser}!.Hope you can follow this short tutorial. Let me know if you need further assistance.
Comment #2
macco commentedThanks,
you put me on the right track.
But I wanted the Drupal ID from the owner of the photo to link to the owners profil.
I apologize for my incomprehensible writing
I did this way now:
I think your tutorial will help me in the future.
By the way, is there a way to use Drupal functions in Gallery2?
Danke,
Marco
Comment #3
macco commentedI close this issue.
Thanks again to profix898.
Regard,
Marco
Comment #4
scott summers commentedSorry i didn't work for me. i tried both the patches but neither $theme['drupaluser'] nor $theme['drupaluserId'] could be accessed in my modules/core/templates/blocks/local/ItemInfo.tpl file. It seems that im missing something.
Comment #5
macco commentedHi,
it seems to me that you placed the code at a wrong location.
In theme.inc should be a part for modules, something like this:
If this doesn't help, please post exactly what you have done including your code.
Marco
Comment #6
scott summers commentedHi macco,
I've added the following code at location: www.mysite.com/gallery2/themes/matrix/theme.inc file.
I tried to use it in modules/core/templates/blocks/local/ItemInfo.tpl file the same way profix898 has suggested i.e. Welcome {$theme.drupaluser}!. but outputs only Welcome !.
Thanks for your kind help.
im new to drupal but appreciate the way people on drupal help others. thanks to drupal and all drupal guys.
I.X.
Comment #7
scott summers commentedsorry i forgot this to ask. i have heard about contact owner module for gallery. but could not find it. could you please tell me the url or where to find this module for gallery 2.1. i shall be very thankful.
Comment #8
macco commentedSorry don't know about blocks.
But you have the function that gives the information to ItemInfo.tpl. That is not theme.inc I guess it should be somewhere in modules/core, I am afraid you have to search a bit.
Comment #9
profix898 commentedTake a look at the user contributed modules (http://codex.gallery2.org/Gallery2:User_Contributions) the contact owner module is listed there as well ...
Its a little more difficult in your case. Blocks are reusable templates that are embedded into other (photo/album) templates. Without telling you too much details, this is what you need to make it work ...
Make the modification to theme.inc as described above (and as you have already tried). Then open photo.tpl (in the templates folder of your theme, e.g. matrix/templates/photo.tpl) and search for a snippet like this:
{g->block type="core.ItemInfo" ... }. That's the code which includes the block template, in this case the 'core.ItemInfo' block. The template is located at modules/core/templates/blocks/ItemInfo.tpl. You must somehow pass the data into your blocks template now and thats what was missing in your attempts to get this working, I guess. The easiest way to achieve this is to add an additional element to the parameter list, that is passed to the block. You can then access this parameter in your block template.Not sure you was able to follow me through the above paragraph!? If not, forget about the theory and take a look at the actual code. Here are the modifications needed to make this work:
1. /themes/matrix/theme.inc:
Take the code as posted above. No further modifications needed.
2. /themes/matrix/templates/photo.tpl:
In this file you search for a section that starts like
{g->block type="core.ItemInfo" ... }and change it to this3. /modules/core/templates/blocks/ItemInfo.tpl
You can now use the new variable like this
Welcome {$drupaluser}!in your block template.To sum up: You first introduce a new theme variable in theme.inc, that will be available for all theme templates such as photo.tpl. You then pass the variable into you block template (ItemInfo.tpl) by adding it to the parameter list of the
{g->block ... }call.As blocks are reusable in several locations, you will notice that the variable will not be available in every case. You will need to modify album.tpl in addition to photo.tpl to make it available for the block on album pages. For this you must search album.tpl for the code that includes the block and add the parameter there as well.
I also suggest that you wrap your code in ItemInfo.tpl like this
to make sure it is only displayed when the variable is actually set.
Hope you got it. Let me know if you need additional help.
Comment #10
scott summers commentedGREAT!!!! profix898, it worked very well for me. Many Thanks again.
Sorry for such a long delay. Actually i was off for days.
Anyway once again many thanks to you and macco for your assistance on this issue. Following your instructions i have also made the username with each thumbnail to link user's drupal profile.
I'm posting the code below if it can be helpful to other users.
ALBUM PAGE CODE
PHOTO PAGE CODE
Once agian Thanks for your help.
I.X.
Comment #11
yngens commentedsubscribe
Comment #12
(not verified) commentedComment #13
plan9 commentedDoes this method still work with the latest version of gallery 2.3?
I'm using Ice theme.
Thanks for any info
G
Comment #14
plan9 commentedI've also tried the above with Matrix and it still doesn't work. I'm assuming therefore that the above method is incompatible with gallery 2.3
Can anyone else please verify?
Thanks
G
Comment #15
plan9 commentedAny chance of an update for gallery 2.3 please?
Comment #16
plan9 commentedHello...
Anyone....?
Comment #17
plan9 commentedClosing this issues as gallery module is now dead