Welcome to the new HowToJoomla!

We've completely revamped the design to make the site easier to read and easier to navigate. We hope you like the changes!

CBAuthorBot Hack

September 13, 2006 | by Cory | 12 Comments

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;
    }
 
 
?>
 

About the Author

Cory WebbIn the years since Joomla! was founded, Cory has built dozens of websites with Joomla! and helped thousands of people find answers to questions about Joomla! through HowToJoomla.net. Cory has also written a book about Joomla titled Beginning Joomla! Web Site Development published by Wrox in April, 2009. In February of 2008, Cory founded Cory Webb Media, LLC, where he provides consulting and web development services for companies of all sizes. You can follow Cory on Twitter @corywebb, or become a fan of Cory Webb Media on Facebook.

Read More

Trackback(0)

Comments (12)Add Comment

0
...
written by Jom, June 02, 2007
Thanks for the post!
0
...
written by Ron, August 18, 2007
Fantastic hack!

I was looking everywhere for this.
Thank You Thank You! smilies/grin.gif
0
...
written by Mika, October 18, 2007
Where can we find the CBAuthorBot?? In what file is that?.. smilies/cry.gif
0
...
written by Mika, October 18, 2007
How to use this?... where?
0
...
written by Mika, October 18, 2007
where is that CBAuthorBot.php?.... is it already present in the CB files? or.. where can I download it.???
0
...
written by Mika, October 18, 2007
where can i download this bot? pls???
62
...
written by Cory, October 18, 2007
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.
0
...
written by Janosch71, October 20, 2007
Hi,

thank you very much for this hack. One question:

you wrote:

You probably already noticed this, but I put class="authorimg" in the "
0
...
written by fabs, November 11, 2007
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
0
...
written by fabs, November 12, 2007
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?
0
...
written by fabs, November 12, 2007
i tried to do the merge myself... only parse errors adn missing functions. no experience, sorry. hope you can help
0
...
written by barryforever, December 08, 2007
Hello i found this hack interesting but how to display username instead first name and last name

Write comment

You must be logged in to post a comment. Please register if you do not have an account yet.

busy