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 CommentsIf 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
In 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.
Trackback(0)
Comments (12)
written by Ron, August 18, 2007
I was looking everywhere for this.
Thank You Thank You!
written by Mika, October 18, 2007
written by Cory, October 18, 2007
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.
written by Janosch71, October 20, 2007
thank you very much for this hack. One question:
you wrote:
You probably already noticed this, but I put class="authorimg" in the "
written by fabs, November 11, 2007
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
written by fabs, November 12, 2007
Cory, do you think you could add the corresponding code snippets for us to enhance cbauthorbot?
written by fabs, November 12, 2007
Write comment





