Please Log in or Create an account to join the conversation.
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.
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.