Who Looked At Me? - Component Work In Progress

Kevin B Posted in Component Development 7 years ago

I'm putting together a "Who Looked At Me?" component for my site.
Using a combination of parts from various components I have the following:

"Who Looked At Me?" link on the front page, that goes to its own page. Currently it just lists all friends, but i'll look at the DB query last. This was modified from the "Friends 4.0" component.

I have also incorporated part of the "Poke" component which should allow me to record each time a person views a profile.

Essentially I need to launch the function addLook($looker, $owner) on document.ready when loading a profile page... but i'm not sure 100% how to do that...

I'm pretty sure if I add it to a button to emulate the Poke action, it'll work, but I need to to run automatically on page load.

Once I have it firing that event, I just need to amend the database query to look through the OSSN_Notifications table for type=wholooked:look and provide the relevant results.

I am happy to release this component publicly for people to do with as they please once its proven working. :)

Broken W.I.P. version can be downloaded here if you think its worth taking a look at?

Who Looked Component

Replies
Afrikaans James Murphy Replied 7 years ago

I really hope you achieve this.

gb Kevin B Replied 7 years ago

That was brilliant thank you Arsalan. It was logging the loggedin user / profile owner the wrong way around, but it was exactly what I needed :)

I have rolled your code into this component and its now working great.

I've stopped it from recording looking at your own profile, but allowed it to record multiple views from the same user (something that will be useful for my users...)

I've added a hook into the topbar_menu as well as the sidemenu.

The only thing left that would be nice to have is to have some pagination. The component has code in there for that - but I couldn't figure it out. If anyone fancies taking a look and fixing that - it would be much appreciated.

For now, I have uploaded the working component here WhoLooked Component

I've never contributed to an Open Source community - so apologies if the formatting etc is wrong. Please feel free to change any information or credits in there. Happy for you guys to do whatever you want with this.

gb Kevin B Replied 7 years ago

that's brilliant thank you I'll take a look. :)

Indonesian Arsalan Shah Replied 7 years ago

@Kevin , Please see the source of component below, i published, its do exactly as you wanted https://www.opensource-socialnetwork.org/component/view/2813/profile-views

gb Kevin B Replied 7 years ago

Doing a little more digging, I think it makes much more sense to do the following:

In the OSSNProfile Component (or your custom copy), have a javascript that just adds a new notification "{user} viewed your profile".

so i'm thinking a modified version of the public function Like, which can be placed in the classes/OssnProfile.php file. All tweaked to add "View" instead of "Like".

This function would somehow need to be called at document.ready, or even just part of the php page load.

Thoughts or pointers much appreciated. :)

gb Kevin B Replied 7 years ago

Hi Malik

This can't go in the Component Store yet because the functionality doesn't work :(

It needs to trigger the "addLook" function on loading the profile page, so that profile views can be stored in the database.

Without this, all you are looking at is your friends list.

Glad you like it, and that it installed without a hitch though. :)

If anybody is able to point me in the right direction of how to do this? Or even knows of an existing component that runs a command on document.ready that I can deconstruct?

Thanks guys
Kev

pk Malik Umer Farooq Replied 7 years ago

sorry for duplicate reply because my net slow and some typo

> and out this component in component store

and put this component in component store

pk Malik Umer Farooq Replied 7 years ago

Thanks for developing grate component for ossn here is live demo
http://malikumer.felahatec.com/ossn/ossn/
username demouser01 password demouser01

Here is few suggestion
look at the image\
enter image description here

Add icon there

  1. when anyone visit profile its update in Who Looked At Me that grate but user also receive notification when click it open that page Who Looked At Me

and out this component in component store
thanks