CBAuthorBot Hack
September 13, 2006 | by CoryIf 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. Cory is also the founder of Themeables, a template club for Joomla!, and developer of /motif, the framework that powers Themeables.






