Twitter
Fri
30
Apr
'10
PDF
Print
Send
 
Hits (560) | Comments (0) | Favorited (1) | Votes (0)

Require basic community integartion plugin knowlige.

Touch have great integration ability to show custom user lists. That is great feature to improve user experience in your extensions. For example you have poll component. It is great way for users to share their opinions or ask questions. But even more interesting if you can see list of users who voted the polls. And even more interested if you can see what vote every user gave on that list. And even more, you can see user rating in your poll component, amount of polls (as link to poll list), …

I want to say that anyone developing user oriented component will discover this as great possibility to extend their applications in few lines of code.

Example of its practical implementation right here. Click on: Hits (xxx) to see list of the users who read this article.

To create a custom user list you need to create URL.

/index.php?option=com_community&view=customlist&client=***

Where *** is the name of your community integration plugin. Name of plugin it is what is stored in element field of #__plugins table in Joomla DB.

And you also attach other parameters you need to know what to show. You URL may looks like this for example if your plugin name is polls

/index.php?option=com_community&view=customlist&client=polls&act=show_voters&poll=23

This URL will trigger event onCustomUserList() and there you may manage your lists.

The example code is as follows.

function onCustomUserList($client, $limitstart, $limit)
{
    if ($client != 'poll') { return; }
            
 
    $users = $this->GetUserData($limitstart, $limit);
    $total = $this->GetUserTotal();
    Foreach($users AS $i => $user)
    {
        $users[$i]->custom_data = ‘Said Yes’;
    }
    
    $return = new StdClass();
 
    $return->page_title = JText::_(‘What Users Say on poll of’).$user_name;
    $return->total = $total;
    $return->description = JText::_(‘This is list of those who voted pool “WWWW”. See all polls, … ..’);
    $return->users = &$users;
 
    return $return;
}

Note that if ($client != 'poll') { return; } in the beginning of every community event function is required. $client contain the name of the currently called plugin. So it should be equal to the name of your plugin, in other cases you need to escape function trigger. That is because plugins are not called explicitly in the code.

What you need is to get users. If you want additional details to be shown nearby every user you may add to user objects custom_data property.

$this->getUserData() is not a standard community function. It is supposedly helper function in your own plugin to get needed users.

The object you return is simple. No need to explain it. Just one note that in description you may add HTML text and place there menu of your component.  For example:

See All Polls | See all polls of this user | …

Or even show the result chart/diagram of the poll.

Another idea is to insert search form to search or filter through user lists. For example on poll user list add select dropdown filter 10,20,30,40,50,60,70,80,90,100 which will show all users who voted 10 or all users who voted 50 in this pool.

Total property of return object is required to generate proper page navigation.


Comments

There are no comments for this item

Be the first to leave a comment

Add New Comment
Name:
Email:
Comment:
Attachment
Hide Comment
Security code:
Enter text as you see on image
 
 
What is best way for Download/Installation MightyExtensions?
 


Member Area



Member Activity

We have 1998 guests and 8 members online


MightyTemplate - Professional Joomla Templates