Skip to Content Skip to Menu

CBAuthorBot Hack - Show CB Avatar in articles

  • ccdog
  • ccdog
  • OFFLINE
  • Posts: 21
  • Thanks: 0
  • Karma: 21
18 years 7 months ago #9096 by ccdog
If you change the code in CBAuthorBot.php to the following, it will show the author's picture in the content. You can see it in action at www.lovelearnlive.com

If you use this and find it useful, please post here and let me know. I want to know that this is useful for more than just me. :) Some Karma would be nice too, but it's not necessary. ;)

[code:1]<?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 : 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;
}


?>[/code:1]

Post edited by: ccdog, at: 2006/03/27 05:29

Post edited by: ccdog, at: 2006/03/27 17:26

Please Log in or Create an account to join the conversation.

  • Red1000
  • Red1000
  • OFFLINE
  • Posts: 39
  • Thanks: 0
  • Karma: 1
18 years 7 months ago #9101 by Red1000
I copied your code and pasted it into the .php file and it didn't work... not sure why, it looks great on your site, though!

Joomla 1.0.8 + CB Stable

Please Log in or Create an account to join the conversation.

  • ccdog
  • ccdog
  • OFFLINE
  • Posts: 21
  • Thanks: 0
  • Karma: 21
18 years 7 months ago #9123 by ccdog
OK, I think I just figured it out...

Wherever it says
[code:1]$mosConfig_livesite[/code:1]
you need to change that to
[code:1]$mosConfig_live_site[/code:1]

Post edited by: ccdog, at: 2006/03/27 16:36

Please Log in or Create an account to join the conversation.

  • Red1000
  • Red1000
  • OFFLINE
  • Posts: 39
  • Thanks: 0
  • Karma: 1
18 years 7 months ago #9143 by Red1000
Indeed... great work! Now all I have to do is style the css :)

Thanks! Karma goes...

up! haha

Joomla 1.0.8 + CB Stable

Please Log in or Create an account to join the conversation.

  • ccdog
  • ccdog
  • OFFLINE
  • Posts: 21
  • Thanks: 0
  • Karma: 21
18 years 7 months ago #9161 by ccdog
I'm glad you like it...Thanks for the karma!

On a side note...

You probably already noticed this, but I put class="authorimg" in the "<img..." tag. So, if you want to style the picture, you simply have to use:

img.authorimg {
...
}

Please Log in or Create an account to join the conversation.

  • Red1000
  • Red1000
  • OFFLINE
  • Posts: 39
  • Thanks: 0
  • Karma: 1
18 years 7 months ago #9162 by Red1000
sure did, thanks!

Joomla 1.0.8 + CB Stable

Please Log in or Create an account to join the conversation.

Moderators: beatnantkrileon
Powered by Kunena Forum