Skip to Content Skip to Menu

CBAuthorBot Hack - Show CB Avatar in articles

  • pateta12
  • pateta12
  • OFFLINE
  • Posts: 30
  • Thanks: 0
  • Karma: 5
18 years 5 months ago #15763 by pateta12
micoots wrote:

Hi,

I'm a bit lost in this thread. I'm trying to find the plugin for download but can't find it anywhere.

What am I missing?

Thanks.

Michael.



You will find the original plugin here: www.joomlapolis.com/component/option,com_docman/task,cat_view/gid,35/Itemid,36/
If you want to use the hack, you will have to do this:

ccdog wrote:

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.

18 years 5 months ago #15842 by ericfoster3
Replied by ericfoster3 on topic CBAuthorBot Hack - Avatar popup on mouseover
Here's a new twist to the same idea. I hacked CBAuthorBot to display the avatar in a popup when you mouseover it.

This also works in my Newest Users module, and Who Is Online module.

Check it out at my site to see what I am talking about.

Post edited by: ericfoster3, at: 2007/02/14 19:20

CB 3rd Party Developer: DatsoTab | KarmaTab
Joomla! 1.0.10
Community Builder 1.0
joomlaboard 1.1.2

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

  • ccdog
  • ccdog
  • OFFLINE
  • Posts: 21
  • Thanks: 0
  • Karma: 21
18 years 5 months ago #15855 by ccdog
ericfoster3 wrote:

Here's a new twist to the same idea. I hacked CBAuthorBot to display the avatar in a popup when you mouseover it.

This also works in my Newest Users module, and Who Is Online module.

Check it out at my site to see what I am talking about.

Arundel Class of 1983


Nice hack! Where's the code?

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

  • ffaabbss
  • ffaabbss
  • OFFLINE
  • Posts: 94
  • Thanks: 0
  • Karma: 6
18 years 5 months ago #15887 by ffaabbss
Here another tweak: This code shows the avatar on the content article, but you have the possibility to switch it off in certain content items inserting this at the beginning of you content item in html [code:1]<!--{!CBAuthorBot}-->[/code:1] ...
All the credits for this go to Azrul over at azrul.com who develops jomcomment.

authorbot code:
[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;

if(strstr($row->text, "!CBAuthorBot"«»)){
return;
}

//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\" hspace=\"4\" vspace=\"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;
}


?>
[/code:1]

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

  • fwd
  • fwd
  • OFFLINE
  • Posts: 6
  • Thanks: 0
  • Karma: 2
18 years 4 months ago #16474 by fwd
Hi All,

Heres the CBAuthorBot with a few changes:

1) shows author photo only when viewing the content item
2) switch off CBAuthorBot in chosen content items as explained above

[code:1]function CBAuthorBot (&$row, &$params, $page) {
global $database, $mosConfig_live_site;

// a few configs
$caption = 'About the Author'; // caption below author image
$show_all = false; // set to true to show author image everywhere

// allow usage of <!-- !CBAuthorBot --> to NOT show the author bot details
if(strstr($row->text, "!CBAuthorBot"«»)){
return;
}

$task = mosGetParam($_REQUEST, 'task', false);
$option = mosGetParam($_REQUEST, 'option', false);

//var_dump($row);
if ( ( ($option == 'com_content' || $option == 'content') && $task == 'view') || $show_all) {
$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 = "<div class=\"author_profile\" style=\"float:left;\"><a href=\"".sefRelToAbs('index.php?option=com_comprofiler&task=userProfile&user='.$row->created_by)."\" align=\"left\"><img src=\"$avatarlink\" border=\"0\"class=\"authorimg\" /><div id=\"authorimg_caption\">$caption</div></a></div>";
}
$row->text = $txt.$row->text;
}
$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>";

}[/code:1]

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

  • Phleum
  • Phleum
  • OFFLINE
  • Posts: 17
  • Thanks: 0
  • Karma: 1
18 years 4 months ago #17446 by Phleum
Here's another tweaking. It's based on above and some of the other things in this thread. This version has the controls from the one above, plus pulls an additional field from community builder (in my case, it's cb_biography). and sticks it under the avatar. city would work, as someone had previously requested.

It's probably redundant the way I did the queries- I don't know PHP/MySQL well. If anyone can clean it up, great. It seems to be working for me, though.

[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;

// a few configs
$query = "SELECT cb_biography FROM #__comprofiler WHERE user_id = $row->created_by AND avatarapproved = '1'";
$database->setQuery( $query );
$cb_biography = $database->loadResult();
$caption = $cb_biography; // caption below author image
$show_all = false; // set to true to show author image everywhere

// allow usage of <!-- !CBAuthorBot --> to NOT show the author bot details
if(strstr($row->text, "!CBAuthorBot"«»)){
return;
}

$task = mosGetParam($_REQUEST, 'task', false);
$option = mosGetParam($_REQUEST, 'option', false);

//var_dump($row);
if ( ( ($option == 'com_content' || $option == 'content') && $task == 'view') || $show_all) {
$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/'.$avatar;
$txt = "<div class=\"author_profile\"><a href=\"".sefRelToAbs('index.php?option=com_comprofiler&task=userProfile&user='.$row->
created_by)."\" align=\"left\"><img src=\"$avatarlink\" border=\"0\"class=\"authorimg\" /><div class=\"authorimg_caption\">$caption</div></a></div>";
}
$row->text = $txt.$row->text;
}
$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>";

}[/code:1]

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

Moderators: beatnantkrileon
Powered by Kunena Forum