JomSocial Integration

DAvatar content plugin (plg_content_davatar) lets you insert users avatars into articles and use it in different extensions.

JomSocial Integration

Postby LiShaoran » Fri Mar 19, 2010 4:22 am

Excellent plugin, great work. Could you explain which lines are responsible for calling the avatar profile in JomSocial and would like to integrate DAvatar in another component for example?

Thanks, keep the good work

LiShaoran
 
Posts: 6
Joined: Fri Mar 19, 2010 4:20 am

Re: JomSocial Integration

Postby Darkick » Fri Mar 19, 2010 5:52 am

It's hard to show only JomSocial part of the plugin code, because the plugin not simple and very complex.
But it's very easy to use it in different extensions. All my extensions from the site uses DAvatar plugin.
Simplest example you can find in the JComments DAvatar plugin.

If you have installed and configured DAvatar plugin you can use such code in your extensions:
Code: Select all
JPluginHelper::importPlugin('content', 'davatar');
$dispatcher = &JDispatcher::getInstance();
...
$user_id = _here_you_get_any_user_id_;
...
$davatar = '{davatar id='.$user_id.'}';  // prepare plugin string
$dispatcher->trigger('onPrepareContentAvatars', array(&$davatar));  // call plugin handler
echo $davatar; // now in  $davatar  variable avatar image with profile link are situated  

Darkick
 
Posts: 204
Joined: Fri Sep 04, 2009 10:16 pm
Location: Russia, Ekaterinburg

Re: JomSocial Integration

Postby LiShaoran » Fri Mar 19, 2010 5:02 pm

OMG worked perfectly, thank you! But I am still having a problem: I can't set my $user_id automatically, if I put manually works, but the idea is that it calls ID alone.

Thanks again!!

LiShaoran
 
Posts: 6
Joined: Fri Mar 19, 2010 4:20 am

Re: JomSocial Integration

Postby Darkick » Fri Mar 19, 2010 6:34 pm

Do you mean user id of the current user? Try this:
Code: Select all
...
$user = &JFactory::getUser();
$user_id = $user->id;
...
 

Darkick
 
Posts: 204
Joined: Fri Sep 04, 2009 10:16 pm
Location: Russia, Ekaterinburg

Re: JomSocial Integration

Postby LiShaoran » Fri Mar 19, 2010 8:05 pm

Thanks again Darkick, but what I want is the ID of the author of the article writing. The way you explained captures the User ID that is logged at the time, instead of showing the avatar of the author of the article.

Thanks for the help.

LiShaoran
 
Posts: 6
Joined: Fri Mar 19, 2010 4:20 am

Re: JomSocial Integration

Postby Darkick » Fri Mar 19, 2010 8:43 pm

Where do you want to show avatar? In the standard Joomla article? The plugin can show authors of articles — you can find parameters. Also you can insert in any place of an article text
Code: Select all
{davatar}

to show avatar of the author of the article in this place.

Darkick
 
Posts: 204
Joined: Fri Sep 04, 2009 10:16 pm
Location: Russia, Ekaterinburg

Re: JomSocial Integration

Postby LiShaoran » Fri Mar 19, 2010 9:09 pm

In SuperBlogger Plugin of JoomlaWorks

The original lines are:
Code: Select all
// Author email & avatar
         if($articleAuthorAvatar || $articleAuthorLatest){
            $queryAuthor = 'SELECT id,email FROM `#__users` WHERE name="'.$row->author.'" LIMIT 1';
            $db->setQuery( $queryAuthor );
            $queryAuthor = $db->loadObjectList();
            
            $output->authorEmail = $queryAuthor[0]->email;
            
            $avatarDefault = SuperBlogger::getTemplatePath($plg_name,'images/avatar.png');
            $avatarDefault = $avatarDefault->http;
            $avatarSize = 80;      
            $output->authorAvatarURL = "http://www.gravatar.com/avatar.php?gravatar_id=".md5(strtolower($output->authorEmail))."&default=".urlencode($avatarDefault)."&size=".$avatarSize;
         }


With your help i got this:

Code: Select all
// Author email & avatar
         if($articleAuthorAvatar || $articleAuthorLatest){
            $queryAuthor = 'SELECT id,email FROM `#__users` WHERE name="'.$row->author.'" LIMIT 1';
            $db->setQuery( $queryAuthor );
            $queryAuthor = $db->loadObjectList();         
            $output->authorEmail = $queryAuthor[0]->email;
            $avatarSize = 80; 
            
            JPluginHelper::importPlugin('content', 'davatar');
                                $dispatcher = &JDispatcher::getInstance();
            $user = &JFactory::getUser();
                                $user_id = $user->id;
                                $davatar = '{davatar id='.$user_id.'}';
                                $dispatcher->trigger('onPrepareContentAvatars', array(&$davatar));   
            $output->authorAvatarURL = $davatar;
         }


But the ID to be displayed is the author of the article instead of user who is logged at the time.

LiShaoran
 
Posts: 6
Joined: Fri Mar 19, 2010 4:20 am

Re: JomSocial Integration

Postby Darkick » Fri Mar 19, 2010 9:52 pm

Try to use this code:
Code: Select all
    // Author email & avatar
             if($articleAuthorAvatar || $articleAuthorLatest){
                JPluginHelper::importPlugin('content', 'davatar');
                $dispatcher = &JDispatcher::getInstance();
                $davatar = '{davatar name='.$row->author.'}';
                $dispatcher->trigger('onPrepareContentAvatars', array(&$davatar));   
                $output
->authorAvatarURL = $davatar;
             } 

In this case we don't need to know user ID, because we know user name — $row->author. We can use it.

Darkick
 
Posts: 204
Joined: Fri Sep 04, 2009 10:16 pm
Location: Russia, Ekaterinburg

Re: JomSocial Integration

Postby LiShaoran » Fri Mar 19, 2010 10:07 pm

Thank you!! I can't believe it worked, I spent several days trying to make it work and could not. I would not have done it without your great help and your awesome plugin.
How could I thank you?

LiShaoran
 
Posts: 6
Joined: Fri Mar 19, 2010 4:20 am

Re: JomSocial Integration

Postby Darkick » Fri Mar 19, 2010 10:19 pm

Glad to help.
You can help by leaving a review ;)

Darkick
 
Posts: 204
Joined: Fri Sep 04, 2009 10:16 pm
Location: Russia, Ekaterinburg

Re: JomSocial Integration

Postby LiShaoran » Fri Mar 19, 2010 10:48 pm

Done! Thanks for all help
Keep the excellent work

LiShaoran
 
Posts: 6
Joined: Fri Mar 19, 2010 4:20 am

Re: JomSocial Integration

Postby Darkick » Sat Mar 20, 2010 10:57 am

Thank! 8-)

Darkick
 
Posts: 204
Joined: Fri Sep 04, 2009 10:16 pm
Location: Russia, Ekaterinburg

Re: JomSocial Integration

Postby dimelotodo » Mon Mar 22, 2010 8:54 am

Hi Darkick,

I am using your plugin, which is great, with the jomsocial hack shown here but my formatting is a bit off.

you can see an example here:

http://dimelotodo.net/portada/el-rincon ... sar-a-180o

Any help would be great

Thanks

dimelotodo
 
Posts: 7
Joined: Mon Mar 22, 2010 8:49 am

Re: JomSocial Integration

Postby Darkick » Mon Mar 22, 2010 9:48 am

Yeah. Looks strange.
Post complex info here: screenshot of the plugin settings, used code, etc.

Darkick
 
Posts: 204
Joined: Fri Sep 04, 2009 10:16 pm
Location: Russia, Ekaterinburg

Re: JomSocial Integration

Postby dimelotodo » Mon Mar 22, 2010 11:20 am

Damn Thanks for the fast reply!! :lol:

Here is the code used in superblogger.php

Code: Select all
   // Author email & avatar
      }
         if($articleAuthorAvatar || $articleAuthorLatest){
                JPluginHelper::importPlugin('content', 'davatar');
                $dispatcher = &JDispatcher::getInstance();
                $davatar = '{davatar name='.$row->author.'}';
                $dispatcher->trigger('onPrepareContentAvatars', array(&$davatar));   
                $output->authorAvatarURL = $davatar;
           
         
         if($articleAuthorAvatar || $articleAuthorLatest){
            $queryAuthor = 'SELECT id,email FROM `#__users` WHERE name="'.$row->author.'" LIMIT 1';
            $db->setQuery( $queryAuthor );
            $queryAuthor = $db->loadObjectList();
            
            
            $output->authorEmail = $queryAuthor[0]->email;
            
            /*$avatarDefault = SuperBlogger::getTemplatePath($plg_name,'images/avatar.png')->http;
            $avatarSize = 80;   
                                       
            $output->authorAvatarURL = "http://www.gravatar.com/avatar.php?gravatar_id=".md5(strtolower($output->authorEmail))."&default=".urlencode($avatarDefault)."&size=".$avatarSize;*/
         }
         


and here are settings for both plugins:
screencap_davatar_plug.tiff
screencap_davatar_plug.tiff (131.34 KiB) Viewed 684 times

screencap_superblogger_plg.tiff
screencap_superblogger_plg.tiff (179.79 KiB) Viewed 684 times

dimelotodo
 
Posts: 7
Joined: Mon Mar 22, 2010 8:49 am

Re: JomSocial Integration

Postby Darkick » Mon Mar 22, 2010 12:00 pm

Why did you used both part of code: mine and original? :)
You need only this part:
Code: Select all
       // Author email & avatar
             
if($articleAuthorAvatar || $articleAuthorLatest){
                    
JPluginHelper::importPlugin('content''davatar');
                    
$dispatcher = &JDispatcher::getInstance();
                    
$davatar '{davatar name='.$row->author.'}';
                    
$dispatcher->trigger('onPrepareContentAvatars', array(&$davatar));   
                    
$output->authorAvatarURL $davatar

to get avatar.

Darkick
 
Posts: 204
Joined: Fri Sep 04, 2009 10:16 pm
Location: Russia, Ekaterinburg

Re: JomSocial Integration

Postby dimelotodo » Mon Mar 22, 2010 3:35 pm

because otherwise the "latest articles" didn't display

dimelotodo
 
Posts: 7
Joined: Mon Mar 22, 2010 8:49 am

Re: JomSocial Integration

Postby Darkick » Mon Mar 22, 2010 4:43 pm

Attach here archive of the full file superblogger.php

Darkick
 
Posts: 204
Joined: Fri Sep 04, 2009 10:16 pm
Location: Russia, Ekaterinburg

Re: JomSocial Integration

Postby dimelotodo » Mon Mar 22, 2010 4:55 pm

I really really appreciate your help!

here is the file:

dimelotodo
 
Posts: 7
Joined: Mon Mar 22, 2010 8:49 am

Re: JomSocial Integration

Postby dimelotodo » Mon Mar 22, 2010 4:58 pm

sorry here it is
jw_superblogger.php.zip
(6.13 KiB) Downloaded 30 times

dimelotodo
 
Posts: 7
Joined: Mon Mar 22, 2010 8:49 am

Next

Return to DAvatar

Who is online

Users browsing this forum: No registered users and 1 guest

cron