1 edb Dec 08, 2005 16:50
3 edb Dec 08, 2005 19:37
Thanks. I'll give it a go and it'll probably get the job done, but I'll keep poking around for a quality answer to the issue. The creative commons people say you should customimze the text a bit instead of the generic text they provide with their licenses, so I'm thinking "This post is the creative work of (link to all posts by author)preferred_name(/link) and is released under a (link to license) creative commons license(/link)" seems kinda cool.
No flying in snow yet, but I'm just south of Phoenix (the city - not the zip) so snow is kinda hard to come by :( On the brighter side, no one sells snow shovels here :D
4 blueyed Dec 08, 2005 19:43
AFAIK there's no clean way yet.
Probably we should pass the Item as param to the render() method.
5 yabba Dec 08, 2005 20:13
blueyed wrote:
AFAIK there's no clean way yet.
Probably we should pass the Item as param to the render() method.
Cool, does that make me the "quality answer" then? :p
¥
6 orta May 23, 2006 16:10
I am trying to write a basic avatars plugin for the latest CVS code I got today, has this situation changed at all?
[edit] After looking at the test plugin, I saw that $params['User'] was used, however, I get
Line : $default_image_path = $params['User'] -> get_media_dir()."avatar.png";
Fatal error: Call to a member function on a non-object in /home/www/roxxoran/therox/b2evolution/blogs/plugins/_avatar.plugin.php on line 52
[\edit]
2nd edit: It seems that $params['User'] doesn't exist in RenderToHTML() so I'll probably try capture it somewhere in another function, not sure what though
7 blueyed May 24, 2006 23:03
There are different $param arrays for each method/hook. And those objects/params get passed which make sense - or at least they should.. :)
I've just committed the change that "Item" gets added to the params for the Render* methods and through this you should get the item's author then.
If you want to have the current, logged in, user instead, use the $current_User global.
8 orta May 25, 2006 12:17
Thanks! I'll post the working plugin once I get the chance to do some coding :)
9 orta May 30, 2006 02:42
needs polish, but its there by pure brute force:
<?php
/**
*
* b2evolution - {@link http://b2evolution.net/}
* Released under GNU GPL License - {@link http://b2evolution.net/about/license.html}
* @copyright (c)2003-2005 by orta - {@link http://therox.org/}
*
* @package plugins
*/
if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
/**
* @package plugins
*/
class avatar_plugin extends Plugin
{
var $code = 'b2ava';
var $name = 'Avatars';
var $priority = 100;
var $version = '0.1';
var $author = 'orta';
var $help_url = 'http://therox.org/';
var $apply_rendering = 'opt-out';
var $number_of_installs = 1;
var $short_desc;
var $long_desc;
/**
* Constructor
*/
function avatar_plugin()
{
$this->short_desc = T_('Add avatars to posts');
$this->long_desc = T_('Add avatars to each posts, they are assigned to the ');
}
/**
* Perform rendering
*
* @param array Associative array of parameters
* (Output format, see {@link format_to_output()})
* @return
boolean true if we can render something for the required output format
*/
function RenderItemAsHtml( & $params )
{
$item = $params['Item'];
$author = $item-> Author;
$default_image_path = '../../media/users/';
$default_image_path .= $author -> nickname . '/';
$default_image_path .= $author -> nickname;
$default_image_path .= '.png';
$content = '<img src = "' . $default_image_path;
$content .= '" class="rightmargin';
$content .= '" />';
$content .= "\n";
$content .= $params['data'];
$params['data'] = $content;
return true;
}
}
?>
10 yabba May 30, 2006 11:01
I may be wrong, but I think that this :-
function RenderItemAsHtml( & $params )
{
$item = $params['Item'];
$author = $item-> Author;
$default_image_path = '../../media/users/';
$default_image_path .= $author -> nickname . '/';
$default_image_path .= $author -> nickname;
$default_image_path .= '.png';
$content = '<img src = "' . $default_image_path;
$content .= '" class="rightmargin';
$content .= '" />';
$content .= "\n";
$content .= $params['data'];
$params['data'] = $content;
return true;
}
Should read like this :-
function RenderItemAsHtml( & $params )
{
global $media_url;
$author = $params['Item']->Author->login;
$default_image_path = $media_url.'users/'.$author.'/'.$author.'.png';
$content = '<img src = "' . $default_image_path;
$content .= '" class="rightmargin';
$content .= '" />';
$content .= "\n";
$content .= $params['data'];
$params['data'] = $content;
return true;
}
¥
11 orta May 30, 2006 12:55
I like that, I've still got a lot to learn with respect to PHP :)
I'm pretty sure that this ISN'T the right way to do it, but that's never stopped you before right? ;)
Hope you got to fly in the snow ;)
¥