Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length

JoomlaTune Support Forum    Other extensions    Plugins    Topic: jcomment avatar for j25
Pages: [1] 2   Go Down
  Print  
Author Topic: jcomment avatar for j25  (Read 10427 times)
0 Members and 1 Guest are viewing this topic.
poonoodi
Newbie
*

Karma: 0
Offline Offline

Posts: 1


« on: July 23, 2012, 22:57:37 »

hi

thanks for  on of best joomla extension  (jcomments)

i need a plugin for display user avatar in jcomment on joomla 2.5

but not found in your products

then :

updated the joomla 1.5 plugin to joomla 2.5
its install on joomla 2.5 successfully
but do not work Sad

this plugin attached

please help me

* plg_jcomments_avatar_j25.zip (21.52 KB - downloaded 242 times.)
Logged
Masoud
Jr. Member
**

Karma: 0
Offline Offline

Posts: 37



« Reply #1 on: August 08, 2012, 23:24:27 »

We are looking forward to it also, but there is no sign of it Tongue

how did you upgrade it to version 2.5?
Logged

----------------------
www.zoomit.ir
jstuardo
Newbie
*

Karma: 0
Offline Offline

Posts: 1


Email
« Reply #2 on: October 15, 2012, 20:53:29 »

Hello...

it is easy to make it work. Just install this plugin, then copy the useful code to jcomments plugin and that's it.

The functions to copy are: onPrepareAvatar and onPrepareAvatars (you need to rename the original one), and replace global $mainframe line to, $mainframe = JFactory::getApplication('site')

Regards,
Jaime
Logged
Wil
Jr. Member
**

Karma: 1
Offline Offline

Posts: 15


« Reply #3 on: October 15, 2012, 21:53:17 »

Hi Jaime, could you a bit more specific. Description in what exactly to do to make it work for Kunena-avatars.
Thanks in advance.
Logged
Bribón
Newbie
*

Karma: 0
Offline Offline

Posts: 6


« Reply #4 on: November 11, 2012, 03:06:25 »

This is what I've found out so far (based on Jaime's suggestion) step by step:

1. Install the old avatar plugin and enable it
2. Open that file (jcomments.avatar.php) and the jcomments plugin (jcomments.php)
3. Copy "plgJCommentsAvatar" and "plgJCommentsAvatars" functions from the first file to the second one. Rename those functions in the first file (any name).
4. In the first file (avatar plugin) copy these lines out of the if structure that stands at the beginning of the file:

$mainframe = JFactory::getApplication('site');
$mainframe->registerEvent('onPrepareAvatar', 'plgJCommentsAvatar');
$mainframe->registerEvent('onPrepareAvatars', 'plgJCommentsAvatars');

(this are the first lines in my case:

<?php
// ensure this file is being included by a parent file
(defined('_VALID_MOS') OR defined('_JEXEC')) or die('Direct Access to this location is not allowed.');
if (JCOMMENTS_JVERSION == '1.0') {
   global $_MAMBOTS;
   $_MAMBOTS->registerFunction('onPrepareAvatar', 'plgJCommentsAvatar');
   $_MAMBOTS->registerFunction('onPrepareAvatars', 'plgJCommentsAvatars');
} else if (JCOMMENTS_JVERSION == '1.5') {
   global $mainframe;
   $mainframe->registerEvent('onPrepareAvatar', 'plgJCommentsAvatar');
   $mainframe->registerEvent('onPrepareAvatars', 'plgJCommentsAvatars');
}

$mainframe = JFactory::getApplication('site');
$mainframe->registerEvent('onPrepareAvatar', 'plgJCommentsAvatar');
$mainframe->registerEvent('onPrepareAvatars', 'plgJCommentsAvatars');

function plgJCommentsGetGravatar($email)
etc.)

5. Save that file and upload it. We're done with this file.
Let's go to the second file (jcomments file, where we had copied those two funcions)
6. In the function plgJCommentsAvatars function replace the global $mainframe by $mainframe = JFactory::getApplication('site');
So the beggining of this function should be something like:

function plgJCommentsAvatars( &$comments )
{
   $mainframe = JFactory::getApplication('site');
   $db = & JCommentsFactory::getDBO();
etc.

7. Very important. If you take a look at the code you'll see a switch function that executes the right code depending on the third party you want to import from. The thing is, as I don't know where that info comes from, just before the switch you have to initialize the variable (used in the switch). In my case, as I wanted to import images from kunena, my code is this one:

   $avatars = array();
   $avatar_type='kunena'; // write here the name of your 3rd party component
    switch($avatar_type) {
etc.

8. Save and upload.

The only problem is that images are shown in different sizes. I'll go on working on this  Grin

Cheers
Logged
Bribón
Newbie
*

Karma: 0
Offline Offline

Posts: 6


« Reply #5 on: November 11, 2012, 03:27:58 »

Uhmm... there must be something wrong in those steps as I get an error message in the admin section...
Logged
Bribón
Newbie
*

Karma: 0
Offline Offline

Posts: 6


« Reply #6 on: November 11, 2012, 03:38:23 »

ok, I think I got it. I'll test it and let you know tomorrow.
Logged
Bribón
Newbie
*

Karma: 0
Offline Offline

Posts: 6


« Reply #7 on: November 11, 2012, 17:28:33 »

Good morning!
It looks like the solution was much easier than I though as the old avatar plugin "almost" works the way it is. There's no need to copy any function, just a couple of changes (or, at least, that's what I think. After so many changes it's difficult to recall correctly what I did to make it work).
So, my updated list of steps to take:

1. Install the old avatar plugin and enable it
2. Open the file (jcomments.avatar.php) and add these lines before the first function:

$mainframe = JFactory::getApplication('site');
$mainframe->registerEvent('onPrepareAvatar', 'plgJCommentsAvatar');
$mainframe->registerEvent('onPrepareAvatars', 'plgJCommentsAvatars');

3. In the "plgJCommentsAvatars" function, replace "global $mainframe;" with "$mainframe = JFactory::getApplication('site');"
4. Before the switch you'll find in that function, add something like "$avatar_type='kunena';" to force the right option (replace "kunena" with your third party component).

And that's all!

The function "plgJCommentsAvatarImg" (in the same file) controls the actual output. So we can define the width or the height of the image. In my case:
function plgJCommentsAvatarImg( $avatar, $alt = '' )
{
   return '<img src="'.$avatar.'" alt="'.$alt.'" border="0" width="48" />';
}

You can see the result here:
http://www.frasesparalahistoria.com

As you can see, these changes also work with the jcomments lastests module...
Logged
Masoud
Jr. Member
**

Karma: 0
Offline Offline

Posts: 37



« Reply #8 on: November 11, 2012, 17:32:01 »

I'll go on check, and let you about the result, Thank you so much in advance.
Logged

----------------------
www.zoomit.ir
Masoud
Jr. Member
**

Karma: 0
Offline Offline

Posts: 37



« Reply #9 on: November 11, 2012, 17:35:28 »

What about K2, would you mind to provide a solution to bring Avatar from K2

Thank you in advance.
Logged

----------------------
www.zoomit.ir
Masoud
Jr. Member
**

Karma: 0
Offline Offline

Posts: 37



« Reply #10 on: November 11, 2012, 17:47:37 »

I change the switch to $avatar_type='k2'; and did all you suggested but still there is no avatar.
Logged

----------------------
www.zoomit.ir
Wil
Jr. Member
**

Karma: 1
Offline Offline

Posts: 15


« Reply #11 on: November 11, 2012, 18:01:29 »

A big thank you for you Bribón  Roll Eyes
I give it a try and will let know if I have succes  Smiley

Works like a charm, perfect. Thanks...
« Last Edit: November 11, 2012, 18:37:50 by Wil » Logged
Bribón
Newbie
*

Karma: 0
Offline Offline

Posts: 6


« Reply #12 on: November 11, 2012, 19:42:09 »

Hi Masoud,
I've never used k2 so I can't test it, but -if the solution for k2 is the same than for kunena, which I don't know-, that should work. Your code should be something like:

...
   $avatars = array();
   $avatar_type='kunena';
    switch($avatar_type)
...

Is that the way you have it?
Logged
Masoud
Jr. Member
**

Karma: 0
Offline Offline

Posts: 37



« Reply #13 on: November 11, 2012, 19:48:34 »

Thank you for answering mine is, this:
Code:
$avatars = array();

$avatar_type='k2';
  switch($avatar_type) {
Logged

----------------------
www.zoomit.ir
Bribón
Newbie
*

Karma: 0
Offline Offline

Posts: 6


« Reply #14 on: November 11, 2012, 20:03:50 »

And that's in line 1? (weird!)
do you want to send that file to no_reply@frasesparalahistoria.com? I can take a look at it...
Logged
Pages: [1] 2   Go Up
  Print  
JoomlaTune Support Forum    Other extensions    Plugins    Topic: jcomment avatar for j25
 
Jump to: