|
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
|
|
Last Updated on Tuesday, 01 September 2009 19:42 |
Comments
Business Travel Tips