News Feed E-mail

Get How-To's right in your inbox. Subscribe to the HowToJoomla! news feed e-mail. Just enter your email address here:

Delivered by FeedBurner

Login






Lost Password?
No account yet? Register

Affiliates

Azrul's JomComment
JoomlaShack
iJoomla
The Joomla! Store
Member of W3C Sites dot com
CBAuthorBot Hack PDF Print E-mail
Written by Cory   
Wednesday, 13 September 2006

If you use Community Builder (CB) and the CBAuthorBot (the one that makes the author's name linkable to their CB Profile), then you might be interested in this hack. It enables you to display the author's CB avatar at the top of an article with a link back to his or her CB profile. I originally posted it here on the CB website. You can go there for more information, and to see how other people have modified the hack.

Here's the code:

 
<?php
/**
* CB Link 2 author mambot
* @package Community Builder
* @subpackage CB Link 2 author mambot
* @Copyright (C) MamboJoe
* @ All rights reserved
* @ Released under GNU/GPL License : http://www.gnu.org/copyleft/gpl.html
* @version $Revision: 1 $
**/
defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
 
$_MAMBOTS->registerFunction( 'onBeforeDisplayContent', 'CBAuthorBot');
 
 
    function CBAuthorBot (&$row, &$params, $page) {
        global $database, $mosConfig_live_site;
 
        //var_dump($row);
        
        $query = "SELECT avatar FROM #__comprofiler WHERE user_id = $row->created_by AND avatarapproved = '1'";
        $database->setQuery( $query );
        $avatar = $database->loadResult();
        $avatarlink = "";
        $txt = "";
        if ( $avatar ) {
            $avatarlink = $mosConfig_live_site.'/images/comprofiler/tn'.$avatar;
            $txt = "<a href=\"".sefRelToAbs('index.php?option=com_comprofiler&task=userProfile&user='.$row->created_by)."\"><img src=\"$avatarlink\" border=\"0\" align=\"left\" class=\"authorimg\" /></a>";
        }
        $row->created_by_alias="<a href=\"".sefRelToAbs('index.php?option=com_comprofiler&task=userProfile&user='.$row->created_by)."\">".($row->created_by_alias!='' ? $row->created_by_alias : $row->author)."</a>";
        $row->text = $txt.$row->text;
        //return $txt;
 
//<div class=\"authorimg\"></div>
        //echo $row->created_by_alias;
    }
 
 
?>
Trackback(0)
Comments (12)add comment
Thanks for the post!
1

report abuse
vote down
vote up
June 02, 2007
Votes: +0
Ron: ...
Fantastic hack!

I was looking everywhere for this.
Thank You Thank You! smilies/grin.gif
2

report abuse
vote down
vote up
August 18, 2007
Votes: +0
Mika: ...
Where can we find the CBAuthorBot?? In what file is that?.. smilies/cry.gif
3

report abuse
vote down
vote up
October 18, 2007
Votes: +0
Mika: ...
How to use this?... where?
4

report abuse
vote down
vote up
October 18, 2007
Votes: +0
Mika: ...
where is that CBAuthorBot.php?.... is it already present in the CB files? or.. where can I download it.???
5

report abuse
vote down
vote up
October 18, 2007
Votes: +0
Mika: ...
where can i download this bot? pls???
6

report abuse
vote down
vote up
October 18, 2007
Votes: +0
Hi Mika,

You can find CBAuthorBot here.

For future reference, you only need to ask once. I am probably in a different time zone than you are, so I was in bed when you asked me the first time.
7

report abuse
vote down
vote up
October 18, 2007
Votes: +1
Janosch71: ...
Hi,

thank you very much for this hack. One question:

you wrote:

You probably already noticed this, but I put class="authorimg" in the "
8

report abuse
vote down
vote up
October 20, 2007
Votes: +0
Hi Cory!
Is there a way to only show the avatar if "show author" is actually enabled for the menu item? I have a blog section link where i said "show author" and another blog section where i do not want to show authors. So I would need to have the bot check whether "show author" is enabled for a blog category, blog section or content item...
how can that be done? could you help me out here?
Thanks
Fabs
9

report abuse
vote down
vote up
November 11, 2007
Votes: +0
I just found out that caldate mambot can be displaye on some sections categories or page only. http://extensions.joomla.org/c...Itemid,35/

Cory, do you think you could add the corresponding code snippets for us to enhance cbauthorbot?
10

report abuse
vote down
vote up
November 11, 2007
Votes: +0
i tried to do the merge myself... only parse errors adn missing functions. no experience, sorry. hope you can help
11

report abuse
vote down
vote up
November 11, 2007
Votes: +0
barryforever: ...
Hello i found this hack interesting but how to display username instead first name and last name
12

report abuse
vote down
vote up
December 07, 2007
Votes: +0

Write comment
quote
bold
italicize
underline
strike
url
image
quote
quote
smile
wink
laugh
grin
angry
sad
shocked
cool
tongue
kiss
cry
smaller | bigger

busy
 
Tag it:
Delicious
Digg
Technorati
< Prev
Advertisement

About HowToJoomla

HowToJoomla was started in September 2006 by me, Cory Webb, a long-time Mambo/Joomla user with a desire to give back to the community that has given so much to him.

HowToJoomla is not the best, most comprehensive Joomla tips site out there. That's not the goal. The goal is to share some of the knowledge and experience that I have gained through years of using the world's best content managment system. I hope that you will find this site useful and visit often. As I come across new tips and ideas, I will post them here for all to see.

I hope you enjoy using HowToJoomla and find it very useful.

Please take some time to read the Disclaimer.

Thanks for visiting!

About Me

I am a 28-year-old husband and father of a beautiful baby girl named Lucy. I have a degree in Electrical Engineering from the University of Texas at Austin, an MBA from Baylor University, and over 4 years experience working with the Mambo/Joomla CMS.

On February 1, 2008, I started a web design, development, and consulting company specializing in designing and developing custom Joomla-powered websites. The new company is aptly named Cory Webb Media, LLC. The double meaning is purely unintentional, but with a last name like "Webb" it is difficult to escape the obvious puns. If you are looking for professional assistance with your website, please feel free to contact me to discuss your project.

I also run HowToJoomla, CoryWebb.com (my personal website/blog), and JoomlaForm.com (a site dedicated to promoting good design in the Joomla! community). In my spare time (if there is such a thing), I volunteer with the youth ministry at my church.

Copyright © 2006 - Cory Webb Media, LLC - All rights reserved.
Powered by Joomla!