<
||
>
How to use CB avatar plugin for article author in general
Written by Elvis, Tuesday, 01 September 2009 19:05   

If you are interested in using this plugin for fetching the avatar from CB in the article content but as article author and you do not want to type {cbavatar} tag all the time read this instructions.

First install the plugin and publish it. Then copy the default.php file from /components/com_content/views/article/tmpl to /templates/MYTEMPLATE/html/com_content/article to avoid loosing modifications on Joomla update. In that file find the If statement: 

<?php if (($this->params->get('show_author')) && ($this->article->author != "")) : ?> 

and replace complete section under it with this piece of code: 

<?php require_once(JPATH_BASE.'/plugins/content/cbavatar.php'); ?>
 <?php if (plgContentCBAvatar::getAvatarUriByUserId($this->article->created_by,true) == '/images/comprofiler/tn') : ?>
  <tr>
  <td valign="top">
  <span class="small">
   <?php JText::printf( 'Written by', ($this->escape($this->article->created_by_alias) ? $this->escape($this->article->created_by_alias) : $this->escape($this->article->author)) ); ?>
  </span>
  </td>
  </tr>
 <?php else : ?>
  <div style="float:right;"><?php echo '<a href="index.php?option=com_comprofiler&task=userProfile&user='.$this->article->created_by.'&Itemid=XXX" mce_href="index.php?option=com_comprofiler&task=userProfile&user='.$this->article->created_by.'&Itemid=XXX"><img src="'.plgContentCBAvatar::getAvatarUriByUserId($this->article->created_by,true).'" mce_src="'.plgContentCBAvatar::getAvatarUriByUserId($this->article->created_by,true).'" width="40px" height="50px" alt="'.($this->escape($this->article->created_by_alias) ? $this->escape($this->article->created_by_alias) : $this->escape($this->article->author)).'">'; ?> </div>
 <?php endif; ?>
 
 

And here is the explanation in english coding :)

check if article parameter says show author and author exist
 then
  load the cb avatar plugin
  check if avatar picture exists for article author
   if not use the existing original code  from Joomla
   if exists
    fetch the avatar
    float it to right
    add a link to the avatar to point to CB profile (Itemid=XXX can be excluded but if you have Menu item attached to the CB profile it is better to use it's ID rather than not since probably you want to preserve same design of the profile on your page including all other modules etc...)
    add a toolitp of author name or author alias on avatar

Thanks to guest author Elvis for this article

Comments

avatar essay writers
0
 
 
How do I set on what normal, minimal or maximum size of avatar is allowed to be uploaded by the article author or are there such option?
avatar Jørn Are
0
 
 
This plugin is only for displaying. Please contact the CB guys for that kind of questions.
avatar Business Travel Tips
0
 
 
I really love this plugin. My friend used it an it's kind of amazing.
avatar Business Travel Tips
0
 
 
And also I've tried to install it but i'm not yet done.
Business Travel Tips
Please login to post comments or replies.
Last Updated on Tuesday, 01 September 2009 19:42