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