Topic-icon Count actions

Active Subscriptions:

None
12 years 8 months ago #37063 by sougatab
Count actions was created by sougatab
Hi Alex,

Suppose we create a button that triggers an open graph action and the "Post to Timeline" pop up appears.
On successful posting, the activity logs should record it. Is there a way to query the total number of successful posts to users' timeline an display on the Joomla frontend?

Thanks!
The topic has been locked.
Support Specialist
12 years 8 months ago #37072 by alzander
Replied by alzander on topic Count actions
Hmmm.. There is a function, but it would only work for the currently logged in user.. not something you could call for any user Id. The code could easily be copied and updated to work for any user Id (if you wanted to show a list of users and the amount of actions they've posted). That code is in the /components/com_jfbconnect/models/opengraphactivity.php file. Specifically, the getTotal or getActivityForUser functions.

I hope that helps get you started with some code, but if you have any other questions, just let me know.

Thanks,
Alex
The topic has been locked.
Active Subscriptions:

None
12 years 8 months ago #37088 by sougatab
Replied by sougatab on topic Count actions
Thanks Alex.
We are looking for a solution that'll work for any user - whether guest (non-logged in) or logged-in.
We just want to show how may previous users have done this open graph activity.
The topic has been locked.
Support Specialist
12 years 8 months ago #37100 by alzander
Replied by alzander on topic Count actions
Ahh.. we don't have any built-in calls for that. You'd need to query the database directly to get that information. It should be a pretty simple query on the #__jfbconnect_opengraph_activity table and check how many actions are published with an action_id of 'xx'.

If you need more help doing that, let me know, but the above should hopefully get you started.

Thanks,
Alex
The topic has been locked.
Active Subscriptions:

None
12 years 8 months ago #37106 by sougatab
Replied by sougatab on topic Count actions
Thanks Alex.
I think the query idea is better and easier to implement.

Is there a way to embed this query in a Joomla custom HTML module?
The topic has been locked.
Support Specialist
12 years 8 months ago #37127 by alzander
Replied by alzander on topic Count actions
You wouldn't be able to embed that code into a standard HTML module. However, we would recommend looking at the Flexi Custom Code module. It's free and let's you easily insert PHP into a custom text box.

It's a great little module.

Should you need anything else with this, just let us know.

Thanks,
Alex
The topic has been locked.
Active Subscriptions:

None
12 years 8 months ago #37666 by sougatab
Replied by sougatab on topic Count actions

alzander wrote: Ahh.. we don't have any built-in calls for that. You'd need to query the database directly to get that information. It should be a pretty simple query on the #__jfbconnect_opengraph_activity table and check how many actions are published with an action_id of 'xx'.

If you need more help doing that, let me know, but the above should hopefully get you started.

Thanks,
Alex


Hi Alex,

We have tried to write a query to find the total number of successful actions. We are using MySQL Count() and grouping it by the type of activity. However it has not worked. Do you have a sample PHP script that will query the total number of successful actions and display the number in the Joomla frontend?

Thanks!
The topic has been locked.
Support Specialist
12 years 8 months ago #37670 by alzander
Replied by alzander on topic Count actions
It would look something like:
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select("COUNT(*)")
   ->from($db->qn("#__opengraph_activity"))
   ->where($db->qn("action_id").'=XX')
   ->where($db->qn("status").'=1');
$db->setQuery($query);
$count = $db->loadResult();
That should get you the count of actions that have been published. I didn't run that code directly and just typed it right in, so please check it. If you get an error or other issue, just let us know.

Thanks,
Alex
The topic has been locked.
Active Subscriptions:

None
12 years 8 months ago #37672 by sougatab
Replied by sougatab on topic Count actions
Thanks Alex
That worked like a charm.
The topic has been locked.
Support Specialist
12 years 8 months ago #37681 by alzander
Replied by alzander on topic Count actions
Awesome! Glad to hear that worked. If you need anything else, just let us know.

Thanks,
Alex
The topic has been locked.