Sinisakrisan (Talk | contribs) (→Use JomSocial Avatar) |
|||
(3 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
− | + | Third-party developers can easily integrate JomSocial features into their components. Among other things, Third-party components can: | |
− | + | # Support JomSocial built-in personal messaging system. | |
− | + | # Use JomSocial avatars. | |
− | + | # Use and extend JomSocial user object, CUser. | |
− | + | # Include user actions in JomSocial activity stream and reward users with points. | |
− | + | # Extend JomSocial via new plugins. | |
− | ===Support JomSocial | + | ===Support JomSocial Built-In Personal Messaging System=== |
− | To support private messaging within your component, you can use this snippet | + | |
+ | To support private messaging within your component, you can use this snippet: | ||
<syntaxhighlight lang="php"> | <syntaxhighlight lang="php"> | ||
include_once JPATH_ROOT.'/components/com_community/libraries/core.php'; | include_once JPATH_ROOT.'/components/com_community/libraries/core.php'; | ||
Line 18: | Line 19: | ||
<br /> | <br /> | ||
− | ===Use JomSocial | + | ===Use JomSocial Avatars=== |
− | To | + | To acquire a path to a '''JomSocial Avatar''', you can simply request a cUser object and call a simple getThumbAvatar function to retrieve the avatar url. |
<syntaxhighlight lang="php"> | <syntaxhighlight lang="php"> | ||
include_once JPATH_ROOT.'/components/com_community/libraries/core.php'; | include_once JPATH_ROOT.'/components/com_community/libraries/core.php'; | ||
Line 29: | Line 30: | ||
<br /> | <br /> | ||
− | ===Use and | + | ===Use and Extend JomSocial User Object, CUser=== |
− | JomSocial | + | JomSocial has its own [[JomSocial User Object|user object]] that can be extended further. The following are few examples how can you use it inside your component. |
− | + | ====Getting a User's Friend Count==== | |
− | ====Getting a | + | Retrieving a specific user's friend count is similar to how you would request a CUser object, by calling the getFriendCount method. |
− | + | ||
<syntaxhighlight lang="php"> | <syntaxhighlight lang="php"> | ||
include_once JPATH_ROOT.'/components/com_community/libraries/core.php'; | include_once JPATH_ROOT.'/components/com_community/libraries/core.php'; | ||
Line 42: | Line 42: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
<br /> | <br /> | ||
− | ====Getting a User's | + | ====Getting a User's Status==== |
− | To retrieve the status that is set by the user, load | + | To retrieve the status that is set by the user, load the CUser object and call the method, getStatus. |
<syntaxhighlight lang="php"> | <syntaxhighlight lang="php"> | ||
include_once JPATH_ROOT.'/components/com_community/libraries/core.php'; | include_once JPATH_ROOT.'/components/com_community/libraries/core.php'; | ||
Line 53: | Line 53: | ||
<br /> | <br /> | ||
====Getting a User's Display Name==== | ====Getting a User's Display Name==== | ||
− | Since JomSocial allows displaying name | + | Since JomSocial allows displaying the name with either the username or the real name, use the getDisplayName method from the CUser object. |
<syntaxhighlight lang="php"> | <syntaxhighlight lang="php"> | ||
include_once JPATH_ROOT.'/components/com_community/libraries/core.php'; | include_once JPATH_ROOT.'/components/com_community/libraries/core.php'; | ||
Line 62: | Line 62: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
<br /> | <br /> | ||
− | ====Getting a User's | + | ====Getting a User's Online Status==== |
− | To get the online status of the current user, | + | To get the online status of the current user, use the isOnline method from the CUser object. |
<syntaxhighlight lang="php"> | <syntaxhighlight lang="php"> | ||
include_once JPATH_ROOT.'/components/com_community/libraries/core.php'; | include_once JPATH_ROOT.'/components/com_community/libraries/core.php'; | ||
Line 75: | Line 75: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
<br /> | <br /> | ||
− | ====Getting a User's | + | ====Getting a User's View Count==== |
− | To get a user's view count, | + | To get a user's view count, use the method, getViewCount, from the CUser object. |
<syntaxhighlight lang="php"> | <syntaxhighlight lang="php"> | ||
include_once JPATH_ROOT.'/components/com_community/libraries/core.php'; | include_once JPATH_ROOT.'/components/com_community/libraries/core.php'; | ||
Line 85: | Line 85: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
<br /> | <br /> | ||
− | ====Link to a User's | + | ====Link to a User's Personal Profile Page==== |
− | By using our own library, CRoute, which is a replacement for JRoute, link to any part of JomSocial will have the correct Itemid and will help avoid any duplicate | + | By using our own library, CRoute, which is a replacement for JRoute, the link to any part of JomSocial will have the correct Itemid and will help avoid any duplicate links. |
<syntaxhighlight lang="php"> | <syntaxhighlight lang="php"> | ||
include_once JPATH_ROOT.'/components/com_community/libraries/core.php'; | include_once JPATH_ROOT.'/components/com_community/libraries/core.php'; |
Latest revision as of 05:24, 9 March 2013
Third-party developers can easily integrate JomSocial features into their components. Among other things, Third-party components can:
- Support JomSocial built-in personal messaging system.
- Use JomSocial avatars.
- Use and extend JomSocial user object, CUser.
- Include user actions in JomSocial activity stream and reward users with points.
- Extend JomSocial via new plugins.
Contents
Support JomSocial Built-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 Avatars
To acquire a path to a JomSocial 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="'.$avatarUrl.'">';
Use and Extend JomSocial User Object, CUser
JomSocial has its own user object that can be extended further. The following are few examples how can you use it inside your component.
Getting a User's Friend Count
Retrieving a specific user's friend count is similar to how you would request a CUser object, by calling the getFriendCount method.
include_once JPATH_ROOT.'/components/com_community/libraries/core.php'; // Get CUser object $user = CFactory::getUser( $userid ); $count = $user->getFriendCount(); echo 'Total friends: ' .$count;
Getting a User's Status
To retrieve the status that is set by the user, load the CUser object and call the method, getStatus.
include_once JPATH_ROOT.'/components/com_community/libraries/core.php'; // Get CUser object $user = CFactory::getUser( $userid ); $status = $user->getStatus(); echo 'User Status: ' . $status;
Getting a User's Display Name
Since JomSocial allows displaying the name with either the username or the real name, use the getDisplayName method from the CUser object.
include_once JPATH_ROOT.'/components/com_community/libraries/core.php'; // Get CUser object $user = CFactory::getUser( $userid ); $name = $user->getDisplayName(); echo 'User name: '.$name ;
Getting a User's Online Status
To get the online status of the current user, use the isOnline method from the CUser object.
include_once JPATH_ROOT.'/components/com_community/libraries/core.php'; // Get CUser object $user = CFactory::getUser( $userid ); $isOnline = $user->isOnline(); if( $isOnline ) { echo 'User is online now!'; }
Getting a User's View Count
To get a user's view count, use the method, getViewCount, from the CUser object.
include_once JPATH_ROOT.'/components/com_community/libraries/core.php'; // Get CUser object $user = CFactory::getUser( $userid ); $count = $user->getViewCount(); echo 'Views: ' .$count. '';
Link to a User's Personal Profile Page
By using our own library, CRoute, which is a replacement for JRoute, the link to any part of JomSocial will have the correct Itemid and will help avoid any duplicate links.
include_once JPATH_ROOT.'/components/com_community/libraries/core.php'; // Get CUser object $link = CRoute::_('index.php?option=com_community&view=profile&userid='.$userid); echo '<a href="/.$link." mce_href="http://www.jomsocial.com/.$link.">View user profile</a>';