Kunena 6.2.6 released

The Kunena team has announce the arrival of Kunena 6.2.6 [K 6.2.6] which is now available for download as a native Joomla extension for J! 4.4.x/5.0.x. This version addresses most of the issues that were discovered in K 6.1 / K 6.2 and issues discovered during the last development stages of K 6.2

This category for technical discussions among experienced, skilled developers who either want to integrate own their software with Kunena or who are developing new features for Kunena.

Please introduce yourself and your goals before asking the questions.

Please do not ask questions about when new versions of Kunena will be released. They will not be answered here and may result in locking the topic from further discussion.

Idea Integrating avatars between Kunena and your component

More
11 years 10 months ago - 11 years 10 months ago #1 by Matias
Use your avatars in Kunena

To integrate your avatars into Kunena, you need to create a small plugin. Easiest example how to do it can be found from here . For more examples, please see our existing integrations in here .

This is how the main plugin file looks like:
Code:
<?php defined ( '_JEXEC' ) or die (); class plgKunenaYourComponent extends JPlugin { public function __construct(&$subject, $config) { // Do not load if Kunena version is not supported or Kunena is not installed if (!(class_exists('KunenaForum') && KunenaForum::isCompatible('2.0') && KunenaForum::installed())) return; // TODO: Here you should detect your component and return if detection fails! parent::__construct ( $subject, $config ); $this->loadLanguage ( 'plg_kunena_kunena.sys', JPATH_ADMINISTRATOR ); $this->path = dirname ( __FILE__ ) . '/kunena'; } /* * Get YourComponent avatar integration object. * * @return YourComponentAvatar */ public function onKunenaGetAvatar() { if (!$this->params->get('avatar', 1)) return; require_once "{$this->path}/avatar.php"; return new KunenaAvatarYourComponent($this->params); } }

In the constructor you just need to add detection for your own component, so that plugin doesn't cause any fatal errors if your component isn't installed.

Once you have done that, you just need to implement your own logic to grab your avatar images into avatar.php file (example in here ).

To avoid having too many queries in Kunena pages, you should also implement a function that loads all users at once (put into KunenaAvatarYourComponent class):
Code:
public function load($userlist) { YourFactory::loadUsers($userlist); }

Use Kunena avatars in your component

On the other hand, to get Kunena avatar into your component, you need to start by detecting if Kunena can be found:
Code:
// Detect and initialize Kunena (only needed to do once) if (!(class_exists('KunenaForum') && KunenaForum::isCompatible('2.0') && KunenaForum::installed())) return false; KunenaForum::setup(); return true;

If you want to fetch data from more than one user, you should start by pre-loading all the users you need:
Code:
// BTW: you don't have to put returned users into variable, but sometimes it's useful to have the list $users = KunenaForumUserHelper::loadUsers(array(63,64,65,66,67,68));

And here is the actual code (with 3 variations depending on what you need) to use Kunena avatars in your component:
Code:
// Initialize variables $sizex = $sizey = 90; $class = 'avatar'; $user = KunenaFactory::getUser(); // Get avatar URL "/media/kunena/avatars/path/file.jpg" $avatarUrl = $user->getAvatarURL($sizex, $sizey); // Get avatar <img> tag $avatarHtml = $user->getAvatarImage($class, $sizex, $sizey); // Get profile link with avatar pointing to profile page $userLink = $user->getLink(null, $avatarHtml);

Please note that if Kunena is integrating to another component, avatars and profile page may be pointing to that another component. For example if Kunena uses Gravatars, your component will do the same.
Last edit: 11 years 10 months ago by Matias.
The following user(s) said Thank You: NicholasJohn16

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

More
11 years 9 months ago #2 by NicholasJohn16
Awesome example, Matias.

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

More
11 years 7 months ago #3 by deathbrigner
Is there a way to do something like this but with a url... I'd like to preset my avatars by username... so AE: www.exemple.com/skins/{username}.png ?

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

More
11 years 3 months ago #4 by nefsan
woooowww and SUPER WOOOOOWWWWW. You save me man. i just spend many hours looking for this response. Is the only one on the net. Thanks.

My problem was i wanted to integrate k2 and kunena avatars. So just delete the code in k2 that loads default avatar and replace it for the code of kunena avatar. Now k2 uses kunena avatar.


Really thanks, :woohoo: :silly: :lol: :cheer: :)

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

Time to create page: 0.366 seconds