Topic-icon How can I make individual activity pages 4 custom open graph actions?

Active Subscriptions:

None
Hey Alex...

So I have finally come to a place where I have a few questions about how best to modify one of your views so that it fit my needs. On my site I have 3 custom actions and two different objects that you can use these actions with... I wish to make individual activity pages for each custom action rather than having them all in the one activity view. I was going to duplicate the existing activity view and then go from there but I am not sure if this is the best way? Thought I would at least ask you first? I am pretty handy with php... just not sure exactly how big of a project I am getting into here?

Secondly.... I have a view (in a 3rd party component) that simply lists my open graph objects in a grid.... I am trying to figure out a way to do some sort of check before the page loads (with php) to get all the open graph objects that have already been used and remove them from the grid before they load.... Does that make sense?

Basically from my 3rd party view get an array of all the objects already used with a particular action and then maybe compare that array against the one that produces my grid already to remove any already used objects....

THANK YOU A TON FOR THIS FANTASTIC COMPONENT AGAIN... I HAVE LEARNED A TON WORKING WITH IT :)
The topic has been locked.
Support Specialist
Ryan,
Before we get too far off course.. let me re-state what you're looking for to make sure I'm understanding correctly:
When the user on your site goes to see all the activity that's been posted to Facebook, you want to have separate pages for each action. You don't want a long list of all actions, you want shorter lists of specific actions. Is that correct?

If that's right, then the best way would probably be to not create a whole separate view, but to have an option to add filter to the page. With a filter, the user would be able to set what action types they want to see and you should also be able to create direct links to pages with filters already set. Sounds like something we should add in JFBConnect, actually.. :)

Secondly.... I have a view (in a 3rd party component) that simply lists my open graph objects in a grid.... I am trying to figure out a way to do some sort of check before the page loads (with php) to get all the open graph objects that have already been used and remove them from the grid before they load.... Does that make sense?

Is this like a contest or game or something.. "Here's the actions you haven't done yet"? Specifically, I'm assuming you want to know which actions haven't been used by the current user, not anyone, right?

Again, that's actually pretty do-able I think. I much prefer to clarify these things before going off into the weeds with unrelated code :)

Glad you're learning a lot with JFBConnect. Hope things are clean and easy, but there's always rough edges to everything. We'd love to have your feedback if there's anything we can improve (interface, documentation, some ugly code somewhere). It really helps us to know what could help our users more!

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

None
Hey Alex!.... Thanks for getting back to me...

So Yes... I think a filter would probably be the ideal solution for "duplicating" the views, now that you mention it... Glad I asked... :) Therefore users could select which action(s) they wanted displayed in the results on that page... I will look into how to add a filter param in the meantime! Thx

As for the second part... So here's the deal.... I am making an app that let's my users "clip" (action) "coupons" (objects)... It's not too complex... The "coupons" are really just items within a k2 category called coupons... I then have a fancy template override for my k2 category_item view page so that it lists the k2 items in a grid using masonry... It's a wall of coupons!

Finally, I have a custom action setup for that category called "clip"... and have implemented a custom action button in the view so users can click it and literally "clip" the coupons... An animation shows a pair of scissors cutting out the coupons and then it's removed from the grid... It all works great EXCEPT... if a user refreshes that k2 category_item page it will load coupons (objects) that have already been clipped (action expired for that item) :-/

SO... I am trying to hide any of my coupon (OBJECTS / k2 items) within the k2 category_item view that have already been used with the clip action???

Does that make it more clear?

Thanks for helping,

Ryan :)
The topic has been locked.
Active Subscriptions:

None
Hey Alex... Just wanted to let you know that I sent you a private message with a link to the site as well... It might help illustrate what I am trying to do!

Thanks again for helping,

Ryan
The topic has been locked.
Support Specialist
Ryan,
I did get your link. We're in the last throws of changes and testing for the v5.0 release which is keeping us busy. I haven't had the time to look into this too much further, but the filtering is on our to-do list for either a 5.0.x bug fix release, or the next 5.1 release. If we get something going sooner that's easy to implement, we'll gladly let you know. Hopefully, we'll be able to focus on this mid/late next week, so you know.

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

None
Thanks for the update Alex... Standing by... Also, just a reminder I am after two things:

1) Filtering for the activity view (sounds like it's coming! Thanks)
2) How to remove items / objects from a k2 category_item view that have already been used with the action or have expired! (described above)

Thanks again for helping. I appreciate it!
The topic has been locked.
Support Specialist
Ryan,
Sorry for the delays. The idea and page you've created look really cool. I'd definitely like to see that in action.. and maybe chat with you about using it as a demo of what can be done. We'll discuss that more when we get everything going :)

I don't have a great answer for the filtering yet. v5.0 is coming out this week, and after that, I can see working on the filtering you're looking for. There's quite a few updates for Actions that we have planned for v5.1 that will streamline things a bit and filtering should be one as well.

As for the way to check actions, I can give you some PHP which will check to see if an action has been 'used'. You'd need to add the logic to hide the K2 item (or whatever you want to do) once you've performed the check.
JModelLegacy::addIncludePath(JPATH_SITE . '/components/com_jfbconnect/models');
        $jfbcOgActionModel = JModelLegacy::getInstance('OpenGraphAction', 'JFBConnectModel');
        $urlKey = $jfbcOgActionModel->getUniqueKey('http://yoursite.com/link-to-coupon'); // The URL of the object page
        $action = $jfbcOgActionModel->getAction('12345); // ID of the action you want to check

        // Check to see if the user has disabled the action (if the action is configured to be disable-able) and check if it hasn't been triggered within the timeframe settings
        if ($action->actionReady($urlKey) && $action->enabledForUser())
             $isReady = true;
        else
             $isReady = false;
Looking at our own code, I'm seeing that we could probably have a better "isReady" function that could check a lot more things (like that the action is enabled for the user, the object/url is associated with the action, etc). Right now though, the above should work as long as you make sure the URL is really associated with the action. I can give you more code if you want to do that check at run time as well.

Once you get that isReady variable, you can show/hide whatever you want.

I hope that works well for you, but I just wrote out the code without testing anything. If you have do have any issues or questions, just let us know.

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

None
THANKS!!!! :) I'd love to be featured if we can get it working. I am excited to get the site launched soon... Just a few more pieces of the puzzle to go...

I got the code... I think that will get me close if not all the way to a solution. I am going to play with it tonight and see if I can get something working. I'll report back when I have some more information! Thanks again

I appreciate all the help Alex!...
The topic has been locked.
Support Specialist
Definitely keep us posted on how it goes. v5.0 comes out tomorrow. The same code should work, just so you know. We'll be excited with that release out so that we can clean up a few lingering support questions, like your filtering thing.. that will also then be part of v5.1.. and the cycle continues :)

Best of luck,
Alex
The topic has been locked.
Active Subscriptions:

None
So I have been playing with the code for a bit now... and for some reason they never come back expired... I modified your code a little bit... notes below:
//JFB Connect Action Check Code
$couponUrl = $this->item->link; // I define the path to the object as it's already used in the view ?!?!

JModelLegacy::addIncludePath(JPATH_SITE . '/components/com_jfbconnect/models'); 
$jfbcOgActionModel = JModelLegacy::getInstance('OpenGraphAction', 'JFBConnectModel'); 
$urlKey = $jfbcOgActionModel->getUniqueKey($couponUrl); // The URL of the object page 
$action = $jfbcOgActionModel->getAction('1'); // ID of the action you want to check 

	//  Check if action hasn't been triggered within the timeframe settings 
	if ($action->enabledForUser()) {  // I changed the if statement to just one of the two checks
	     $isReady = true; 
	     
	} else {
	 
	     $isReady = false;
	     
	}
     
     if($isReady == false){ // then I make another if statement based off the isReady variable ?>
     
     alert("Item Already Used"); 
   //  ITEM USED DIV THAT RED ALSO GOES HERE SO I CAN SEE VISUALLY IF IT'S WORKING
    
     if($isReady == true){
           //my normal code to make coupons goes here

Perhaps I am doing something wrong? I tried testing but I am not really sure how to test... As you can see I included a script that should alert if an item comes back as expired?! So far it's never alerted.... I have clicked a ton of the target coupons trying to make sure that one is indeed expired when I test... I have the action set to once daily.... not exactly sure... will keep trying though :)
The topic has been locked.