Skip to Content Skip to Menu

CBAuthorBot Hack - Show CB Avatar in articles

  • bjraines
  • bjraines
  • OFFLINE
  • Posts: 87
  • Thanks: 0
  • Karma: 2
17 years 8 months ago #30323 by bjraines
Here is the code to show the username and avatar if the avatar is published and only the username is the avatar is not approved. Sorry if it looks hacked up , I am but an amatuer. You can find a demo at www.shareyourexpertise.com

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


$query = "SELECT #__comprofiler.avatar, #__users.username FROM #__comprofiler, #__users
WHERE #__comprofiler.user_id = $row->created_by AND #__comprofiler.user_id = #__users.id ";
$database->setQuery( $query );
$results = $database->loadObjectList();
$result=$results[0];
$avatar=$result->avatar;
$username=$result->username;
$avatarlink = "";
$txt = "";
$usernamelink = "<a href=\"".sefRelToAbs('index.php?option=com_comprofiler&task=userProfile&user='.$row->created_by)."\">"
.$username."</a>" ;
$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\" width=\"25px\" class=\"authorimg\" /></a>" ;


$row->created_by_alias=$usernamelink.$txt;
$row->text = $row->text;


}


?>
[/code:1]

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

  • aldanor
  • aldanor
  • OFFLINE
  • Posts: 1
  • Thanks: 0
  • Karma: 0
17 years 8 months ago #30453 by aldanor
Hello, I'm using CB Authorbot, it works ok, but for Newsflashes module I get "Undefined property: stdClass::$created_by" notice - then it turns out that [created_by] is not even defined in newsflashes $row.

Any ideas?

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

  • Naesstrom
  • Naesstrom
  • OFFLINE
  • Posts: 3
  • Thanks: 0
  • Karma: 0
17 years 6 months ago #35440 by Naesstrom
Replied by Naesstrom on topic Re:CBAuthorBot Hack - Avatar popup on mouseover
giapet wrote:

Hi guys,

I'm trying to implement this on my website. I've got it working, but I can't seem to be able to tweak the formatting o_o I'm 99% PHP-stupid, for the record.

I'd like for the icon to show up next to the "written by" message, so that it'll look like:

[IMAGE] Written by [AUTHOR]

I tried the various code fussing that was mentioned in this thread as much as I dared, but I couldn't get it to work out that way.

Most of my posts on the site open with an image, so it always winds up being the icon and then the first image, which looks funny ^^; I'd like to find a way to get this to work out (...without having to just throw a couple of line breaks up at the top of every article).

Thanks very much for any help! :)


Did u ever get it to look like that... I want the image to show up at the "written by" text to...

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

  • Hazzaa
  • Hazzaa
  • OFFLINE
  • Posts: 14
  • Thanks: 0
  • Karma: 2
17 years 6 months ago #35459 by Hazzaa
Hi guys this is the first time I post in here and want to thank everybody for all their hard work. In going through this post (All 12 pages :blink:) I have not found how to implement this particular version.
I keep getting this;
Parse error: parse error, unexpected T_STRING in /.../local/home/.../mywebsite.org/mambots/content/CBAuthorbot.php on line 28.

This is line 28;
if(strstr($row->text, "!CBAuthorBot"«»)){
Can anybody help with this?

Thanks in advance.

Phleum wrote:

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]


Experience is something you get just after you really need it.

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

  • rsmarques
  • rsmarques
  • OFFLINE
  • Posts: 2
  • Thanks: 0
  • Karma: 0
  • Add-ons
17 years 6 months ago #35524 by rsmarques
Replied by rsmarques on topic Re:CBAuthorBot Hack - Show CB Avatar in articles
What I'm doing is very similar, there is just one little difference:

I'm using Mosets Tree and CB to run an article website. Sam Lewis created some nice plugins that make this integration possible. I wrote him but didn't get any response yet...

I use these codes to make the Author name and the Avatar appear in the article.

<?php $this->plugin( 'cbprofilelink', $link, 'name') ?>

<?php $this->plugin( 'cbprofilelink', $this->link, 'avatar') ?>

At the end of the article I want to show the Avatar and the Author Biography right beside (My CB calls the biography field "interests").

I'm not being able to make the Interests/Bio appear there.

Does anyone know how I can accomplish that?

Take a look at the plugin file so you can have an idea.

The page bellow shows the Avatar and Author Name on the top. Scroll down and you'll see the Avatar that I want to show the biography close to it:

I really hope someone can help me! I'm lost and this is the last thing I need to do to make this site a real article directory.

www.artigos.com/artigos/mensagens/rascunho-da-vida-1493/artigo/

Attachment Savant2_Plugin_cbprofilelink_php-eb7ce727c23bebb5c8d89957a1457760.txt not found

Attachments:

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

17 years 4 months ago #38555 by grafixexpress
Replied by grafixexpress on topic Re:CBAuthorBot Hack - Show CB Avatar in articles
yeah this doesn't work - anyone have a solution to display the avatar next to the title?

ccdog wrote:

fwd wrote:

designguru wrote:


Question - how hard would it be to have the avatar image display in line with the content title instead of below it?

q./


Yes, very simple. Instead of adding the image to $row->text, add it to $row->title.

[code:1]function CBAuthorBot (&$row, &$params, $page) {[/code:1]

$row is passed by reference (we are working with the actual variable, not a copy) to CBAuthorBot so that it can be modified before printed on the page.

In CBAuthorBot we are modifiying $row->text to place the image at the beginning of the text (Content Item body).
To place the image in the title would be just to modify $row->title instead.


I'm not sure that will work. I think the code to display $row->title is already executed before this mambot is activated. I could be wrong though.


Post edited by: grafixexpress, at: 2007/05/28 12:08

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

Moderators: beatnantkrileon
Powered by Kunena Forum