Sinisakrisan (Talk | contribs) (→Use JomSocial Avatar) |
Sinisakrisan (Talk | contribs) |
||
Line 2: | Line 2: | ||
Support JomSocial build-in personal messaging system | Support JomSocial build-in personal messaging system | ||
Use JomSocial avatar | Use JomSocial avatar | ||
− | Use JomSocial user object, CUser | + | Use and extend JomSocial user object, CUser |
− | + | ||
Include user action to JomSocial activity stream, and reward user with points | Include user action to JomSocial activity stream, and reward user with points | ||
Extends JomSocial via new plugin | Extends JomSocial via new plugin | ||
Line 26: | Line 25: | ||
$avatarUrl = $user->getThumbAvatar(); | $avatarUrl = $user->getThumbAvatar(); | ||
echo '<img src="/.%20$avatarUrl%20.%20" mce_src="http://www.jomsocial.com/. $avatarUrl .">'; | echo '<img src="/.%20$avatarUrl%20.%20" mce_src="http://www.jomsocial.com/. $avatarUrl .">'; | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | ===Use and extend JomSocial user object, CUser=== | ||
+ | JomSocial have its own [[JomSocial User Object|user object]] that can be extended further. | ||
+ | Here are few examples how can you use it inside your component | ||
+ | ====Getting a user's friend count==== | ||
+ | To retrieve a specific user's friend count, similar like how you would request a CUser object, and call the method getFriendCount. | ||
+ | <syntaxhighlight lang="php"> | ||
+ | $jspath = JPATH_ROOT . DS . 'components' . DS . 'com_community'; | ||
+ | include_once($jspath. DS . 'libraries' . DS . 'core.php'); | ||
+ | // Get CUser object | ||
+ | $user = CFactory::getUser( $userid ); | ||
+ | $count = $user->getFriendCount(); | ||
+ | echo 'Total friends: ' .$count; | ||
</syntaxhighlight> | </syntaxhighlight> |
Revision as of 15:38, 17 January 2013
3rd party component can easily integrate JomSocial features into their component. Among other things, 3rd party other component can
Support JomSocial build-in personal messaging system Use JomSocial avatar Use and extend JomSocial user object, CUser Include user action to JomSocial activity stream, and reward user with points Extends JomSocial via new plugin
Contents
Support JomSocial build-in personal messaging system
To support private messaging within your component, you can use this snippet.
include_once JPATH_ROOT.'/components/com_community/libraries/core.php'; include_once JPATH_ROOT.'/components/com_community/libraries/messaging.php'; // Add a onclick action to any link to send a message // Here, we assume $usrid contain the id of the user we want to send message to $onclick = CMessaging::getPopup($userid); echo '<a onclick="'.$onclick.'" href="#">Send message</a>';
Use JomSocial Avatar
To get path to JS avatar, you can simply request a CUser object and call a simple getThumbAvatar function to retrieve the avatar url.
include_once JPATH_ROOT.'/components/com_community/libraries/core.php'; // Get CUser object $user = CFactory::getUser($userid); $avatarUrl = $user->getThumbAvatar(); echo '<img src="/.%20$avatarUrl%20.%20" mce_src="http://www.jomsocial.com/. $avatarUrl .">';
Use and extend JomSocial user object, CUser
JomSocial have its own user object that can be extended further. Here are few examples how can you use it inside your component
Getting a user's friend count
To retrieve a specific user's friend count, similar like how you would request a CUser object, and call the method getFriendCount.
$jspath = JPATH_ROOT . DS . 'components' . DS . 'com_community'; include_once($jspath. DS . 'libraries' . DS . 'core.php'); // Get CUser object $user = CFactory::getUser( $userid ); $count = $user->getFriendCount(); echo 'Total friends: ' .$count;