Skip to Content Skip to Menu

CBAuthorBot Hack - Show CB Avatar in articles

  • Phleum
  • Phleum
  • OFFLINE
  • Posts: 17
  • Thanks: 0
  • Karma: 1
16 years 8 months ago #58728 by Phleum
Wow- lots of activity since I last checked. here's my version, for what it's worth. It's implemented here: massmees.org/index.php?option=com_content&task=category§ionid=4&id=164&Itemid=540

It's simple: avatar on top, bio below (if available) in box on top left, wrapped by text.

It *should* return either the av, the bio, or both, depending on the user profile. This version requires a CB field "cb_bio" (hardcoded). It would be cool if the choice of field(s) was configurable through parameters. Even better if the whole layout was configurable. Maybe that get into the realm of the module I've read about here...

We use author alias a bunch, so I wrote it to ignore the author if it's the main admin(62).

If you want to hide it from a content item, use the call {!Bio!} or {nobio!} in the item.

Maybe it will help someone...

[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 $
* modified by ccdog then phleum to add author avatars and captions
* -- this version requires a CB field "cb_bio" to function properly
**/
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_bio FROM #__comprofiler WHERE user_id = $row->created_by";
$database->setQuery( $query );
$cb_bio = $database->loadResult();
$caption = $cb_bio; // caption below author image
$show_all = false; // set to true to show author image everywhere

// Do not show general admin-- hardcoded to admin id
if ($row->created_by != 62) {

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

if(strstr($row->text, "nobio!"«»)){
print str_replace("{nobio!}", "", $row->text);

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 || $cb_bio ) {
$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.

  • mediaguru
  • mediaguru
  • OFFLINE
  • Posts: 365
  • Thanks: 1
  • Karma: 70
16 years 7 months ago #59934 by mediaguru
Replied by mediaguru on topic Re:CBAuthorBot Hack - Show CB Avatar in articles
This works great, but the avatars are huge. How do we display the THUMBNAIL and not the original avatar?

CB/Joomla golf site: www.thegolfspace.com
Geek/joomla site: www.tkserver.com

Check out my Joomla/CB projects:

* LIKE thumbs up system for "liking" content items
* Karma - CB user rating system
* Golf Score Tracker
* Jitter - status update system. "What's on your mind?"
* CB Author Plug - Shows CB author link and avatar in content items. J1.5 compatible and very customizable!

Found on my web site or in the Joomlapolis Directory !

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

  • mediaguru
  • mediaguru
  • OFFLINE
  • Posts: 365
  • Thanks: 1
  • Karma: 70
16 years 7 months ago #59935 by mediaguru
Replied by mediaguru on topic Re:CBAuthorBot Hack - Show CB Avatar in articles
I'm so proud of myself. I figured out my own question.

Line 55:

[code:1] $avatarlink = $mosConfig_live_site.'/images/comprofiler/'.$avatar;
[/code:1]

Change to:
[code:1] $avatarlink = $mosConfig_live_site.'/images/comprofiler/tn'.$avatar;
[/code:1]

This loads the thumbnail instead of the full sized avatar.

CB/Joomla golf site: www.thegolfspace.com
Geek/joomla site: www.tkserver.com

Check out my Joomla/CB projects:

* LIKE thumbs up system for "liking" content items
* Karma - CB user rating system
* Golf Score Tracker
* Jitter - status update system. "What's on your mind?"
* CB Author Plug - Shows CB author link and avatar in content items. J1.5 compatible and very customizable!

Found on my web site or in the Joomlapolis Directory !

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

  • mediaguru
  • mediaguru
  • OFFLINE
  • Posts: 365
  • Thanks: 1
  • Karma: 70
16 years 7 months ago #59936 by mediaguru
Replied by mediaguru on topic Re:CBAuthorBot Hack - Show CB Avatar in articles
Here's how I aligned the image to the left with wrapping text and some space around the image, roughly line 56:

[code:1]$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\" align=\"left\" hspace=\"10\" vspace=\"5\" /><div class=\"authorimg_caption\">$caption</div></a></div>";[/code:1]

CB/Joomla golf site: www.thegolfspace.com
Geek/joomla site: www.tkserver.com

Check out my Joomla/CB projects:

* LIKE thumbs up system for "liking" content items
* Karma - CB user rating system
* Golf Score Tracker
* Jitter - status update system. "What's on your mind?"
* CB Author Plug - Shows CB author link and avatar in content items. J1.5 compatible and very customizable!

Found on my web site or in the Joomlapolis Directory !

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

  • darb
  • darb
  • OFFLINE
  • Posts: 65
  • Thanks: 0
  • Karma: 2
16 years 7 months ago #59999 by darb
mediaguru nice! I like your design! anything you can share the css? :P

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

  • mediaguru
  • mediaguru
  • OFFLINE
  • Posts: 365
  • Thanks: 1
  • Karma: 70
16 years 7 months ago #60014 by mediaguru
Replied by mediaguru on topic Re:CBAuthorBot Hack - Show CB Avatar in articles
You are kind. Any css can be "stolen" you know...

CB/Joomla golf site: www.thegolfspace.com
Geek/joomla site: www.tkserver.com

Check out my Joomla/CB projects:

* LIKE thumbs up system for "liking" content items
* Karma - CB user rating system
* Golf Score Tracker
* Jitter - status update system. "What's on your mind?"
* CB Author Plug - Shows CB author link and avatar in content items. J1.5 compatible and very customizable!

Found on my web site or in the Joomlapolis Directory !

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

Moderators: beatnantkrileon
Powered by Kunena Forum