Link to Joomla User ID

gwmbox

Joined: 2007-05-08
Posts: 38
Posted: Tue, 2008-01-01 13:10

Hi all

I am trying to work out how I can get the Joomla user ID, actually via Community Builder as I want to link the owners name to their member profile within Community Builder.

I hope someone can help me out - here is what I have so far - note the ??????? is where I need the User ID.

{if !empty($showOwner)}
<div class="owner summary">
Owner: <a href='/index.php?option=com_comprofiler&task=userProfile&user=???????
{g->text text="%s" arg1=$item.owner.userName|default:$item.owner.fullName}
'>
{g->text text="%s" arg1=$item.owner.userName|default:$item.owner.fullName}
</a>
</div>
{/if}

Cheers

 
serbanc

Joined: 2006-05-19
Posts: 314
Posted: Tue, 2008-01-01 14:19

you can get the J user id via a search into ExternalIdMap table.
this can be done in the php files (.inc) not in the template file (.tpl)

serbanc - www.e-poze.ro

 
gwmbox

Joined: 2007-05-08
Posts: 38
Posted: Tue, 2008-01-01 14:31

That sounds terrific but can you lend a noob a hand and give me a clearer pointer to what I need to look for and edit :)

Cheers for you help

Greg

 
hamzaalraei

Joined: 2008-01-01
Posts: 4
Posted: Tue, 2008-01-01 16:00

LEARN & EARN

King Saud University is organizing a regular weekly based competition: Knowledge for all contests to encourage knowledge web publishing worldwide. As a result helping in building knowledgeble society that can exchange information easily through the internet.

The question of this week is: What do we mean by the term “Electronic Publishing”?
By searching the king Saud university website;
I found the answer and the link for that answer is

www.ksu.edu.sa

http://faculty.ksu.edu.sa/Al-Arishee/Documents/النشر الإلكترونى

Its your chance to learn and earn

 
hamzaalraei

Joined: 2008-01-01
Posts: 4
Posted: Tue, 2008-01-01 16:01

LEARN & EARN

King Saud University is organizing a regular weekly based competition: Knowledge for all contests to encourage knowledge web publishing worldwide. As a result helping in building knowledgeble society that can exchange information easily through the internet.

The question of this week is: What do we mean by the term “Electronic Publishing”?
By searching the king Saud university website;
I found the answer and the link for that answer is

www.ksu.edu.sa

http://faculty.ksu.edu.sa/Al-Arishee/Documents/النشر الإلكترونى

Its your chance to learn and earn

 
hamzaalraei

Joined: 2008-01-01
Posts: 4
Posted: Tue, 2008-01-01 16:02

LEARN & EARN

King Saud University is organizing a regular weekly based competition: Knowledge for all contests to encourage knowledge web publishing worldwide. As a result helping in building knowledgeble society that can exchange information easily through the internet.

The question of this week is: What do we mean by the term “Electronic Publishing”?
By searching the king Saud university website;
I found the answer and the link for that answer is

www.ksu.edu.sa

http://faculty.ksu.edu.sa/Al-Arishee/Documents/النشر الإلكترونى

Its your chance to learn and earn

 
hamzaalraei

Joined: 2008-01-01
Posts: 4
Posted: Tue, 2008-01-01 16:03

LEARN & EARN

King Saud University is organizing a regular weekly based competition: Knowledge for all contests to encourage knowledge web publishing worldwide. As a result helping in building knowledgeble society that can exchange information easily through the internet.

The question of this week is: What do we mean by the term “Electronic Publishing”?
By searching the king Saud university website;
I found the answer and the link for that answer is

www.ksu.edu.sa

http://faculty.ksu.edu.sa/Al-Arishee/Documents/النشر الإلكترونى

Its your chance to learn and earn

 
serbanc

Joined: 2006-05-19
Posts: 314
Posted: Tue, 2008-01-01 20:04

in .inc file, in view class.
global $gallery;

$userId = $gallery->getActiveUserId();

$query = 'SELECT [ExternalIdMap::externalId]
FROM [ExternalIdMap]
WHERE [ExternalIdMap::entityId] = ? AND
[ExternalIdMap::entityType] = ? LIMIT 1';

list($ret, $SearchResults) = $gallery->search($query, array($userId, 'GalleryUser'));
if ($ret) {
/* Serban: treat error */
}

while ($result = $SearchResults->nextResult()) {
$externalId = $result[0];
}

Now, add externalId to the list of variables available to the template. something like
$TemplateName['externalId'] = $externalId;

then, in template use this as
$TemplateName.externalId

enjoy!
serbanc - www.e-poze.ro

 
gwmbox

Joined: 2007-05-08
Posts: 38
Posted: Wed, 2008-01-02 00:20
Quote:
in .inc file, in view class.

OK what do you mean here - what .inc file or do I need to create a new one and do you mean GalleryView.class?

Thanks again

Greg

(P.S what is with all the spam?)

 
serbanc

Joined: 2006-05-19
Posts: 314
Posted: Wed, 2008-01-02 12:22

I assume that you want to display that information in one of the existing pages of the gallery.
So , you need to enter the code in the .inc file that generates that page (view) and to display it via some code (your code!) in a .tpl file.

if you give more details, like "I want to display it in...." I can help you more.
serbanc - www.e-poze.ro

 
gwmbox

Joined: 2007-05-08
Posts: 38
Posted: Wed, 2008-01-02 12:37

OK thanks it is on the photo view (photo.tpl) and album view (album.tpl) where I have set the owner to show the username rather than the users real name. I am wanting to link that username to the users profile in Community Builder. So I am guessing the ShowItem.inc file?

Cheers again for your help :)

 
serbanc

Joined: 2006-05-19
Posts: 314
Posted: Wed, 2008-01-02 16:30

in this case, you should put the code into theme.inc, into the functions showAlbumPage and showPhotoPage.

the code would change like (only in the last line)
$theme['externalId'] = $externalId;

and the reference in .tpl would be
$theme.externalId

serbanc - www.e-poze.ro

 
gwmbox

Joined: 2007-05-08
Posts: 38
Posted: Thu, 2008-01-03 01:21

serbanc I thank you for your patience with me but I must be doing something wrong as I cannot get it to work. In any case it is actually the ItemInfo.tpl file I need it in - sorry my mistake.

I'll keep fiddling and see what I can come up with :)

Cheers

Greg

 
Brat

Joined: 2003-08-03
Posts: 50
Posted: Mon, 2008-02-25 08:52

Hey, just wanted to post back a "thank you" to serbanc for pointing me in the right direction, and my gratitude to the folks at Drupal for the bulk of the function code.

I'm customizing the NZDI theme, and finally defined the variable $theme.item.owner.externalId so I now have my Joomla user Id (and therefore can build my CB link). So, for those searching for this solution, here is how I got it to work.

1) Backup your original theme.inc file. Unless I missed something in the documentation, it looks like you cannot use a "local" version of this file.
2) In my showAlbumPage and showAlbumPage functions, I added the following code before the line return array(null, 'theme.tpl'); (which, btw, is the last line in both functions):

/* Add in our extra stuff */
$theme =& $template->getVariableByReference('theme');
global $gallery;
$query = "SELECT g_externalId  FROM g2_ExternalIdMap WHERE g_entityId='".$theme['item']['owner']['id']."' AND g_entityType='GalleryUser'";
$results = $gallery->search($query);
$externalId = $results[1]->nextResult();
$theme['item']['owner']['externalId'] = $externalId[0];

You can now use the variable $theme.item.owner.externalId in your album and photo page templates to get the Joomla user id. Your function names may be different depending upon what theme you're using, but you get the idea - add this code to your "show" or "view" functions.

NOTE: only add the "$theme =&" line if you don't have it already in the function.

Hope this helps!

 
stutteringp0et

Joined: 2008-02-27
Posts: 4
Posted: Wed, 2008-02-27 17:47

I use the {runphp} plugin to accomplish this, here's the code. This should be useable (minus the {runphp} tags) in virtually any joomla component or module you might want to make.

This code determines the top-level gallery ID owned by the current user. The output of this code would be added to your gallery URL as the value of g2_itemId

Quote:
{runphp}
global $database,$my;
/* query finds the g2 user id when provided J! user id */
$query="SELECT * FROM g2_ExternalIdMap WHERE g_entityType = 'GalleryUser' AND g_externalId = ".$my->id;
$database->setQuery($query);$database->loadObject( $g2id );
/* in the next line, it's important to determine the root g2_itemID of the gallery you're interested in, or the gallery which contains your users. For me, it's 23, for you, who knows...good luck */
$query="SELECT * FROM `g2_Item` LEFT JOIN g2_ChildEntity ON g2_ChildEntity.g_id = g2_Item.g_id WHERE g2_ChildEntity.g_parentid = 23 AND g2_Item.g_ownerId = ".$g2id->g_entityId;
$database->setQuery($query);
$database->loadObject( $gallery );
echo $gallery->g_id;
{/runphp}

From inside the gallery linking back to a user profile (like community builder), it's equally not so bad.

Quote:
{runphp}
global $database,$my,$_GET;
/* first, find the owner of the current gallery and query gallery for the owner */
$query="SELECT g_ownerId FROM `g2_Item` where g_id = ".$_GET['g2_itemId'];
$database->setQuery($query);
$database->loadObject( $gallery );
/* then find the J! userid based on G2 owner */
$query="SELECT g_externalId FROM g2_ExternalIdMap WHERE g_entityType = 'GalleryUser' AND g_entityId = ".$gallery->g_ownerId;
$database->setQuery($query);
$database->loadObject( $gallery );
echo $gallery->g_externalId;
{/runphp}

Personally, I use these code snippets in a strange way in Joomla. I've modified the core and database to allow me to use mambots inside menu items (text and URL), and just about anywhere else I can think of to stick them. So for me, the gallery, profiles, upload links, and everything reside in menuitems. I'm working on removing the gallery sidebar entirely, replaced with my styled menu items.

So, now that I feel I've contributed to this forum, I'll go to a different topic and post my question.

Enjoy!

 
Dukessa

Joined: 2008-05-07
Posts: 8
Posted: Mon, 2008-05-19 02:07

Ok, Im totally lost here.
I have Gallery 2.2.4 and Joomla 1.5.3
I use the X_treme Theme for the Gallery.
The Gallery is embedded into Joomla thanks to the "Gallery 2 bridge" component.
Users are mapped directly from Joomla database (so they are exactly the same one Gallery = Joomla)

What I'd like is that the Album "Owner" nickname links to the Community Builder user profile, in Joomla.

For example in this image:

[img]http://img177.imageshack.us/img177/7255/glinkqs7.jpg[/img]

I'd like that "Dukessa" becomes a link to my Community Builder profile page, in Joomla.

How can I do this?

Thank you!