Finding a way to mark articles published after last user visit

For Joomla! 3.x Coding related discussions, you could also use: http://groups.google.com/group/joomla-dev-general

Moderators: ooffick, General Support Moderators

Forum rules
Locked
arek1
Joomla! Apprentice
Joomla! Apprentice
Posts: 24
Joined: Sun Jul 29, 2007 6:06 pm

Finding a way to mark articles published after last user visit

Post by arek1 » Mon Sep 17, 2018 7:48 am

Hi,

I am creator and administrator of small intranet website in our company. I am trying to find a way to mark (different color or something else) articles published after last visit of current user. Actually I am stuck. What I've tried until now:

1. I was trying to make it in Template override:
$user = JFactory::getUser();
and then compare $user->lastvisitDate with $this->item->publish_up (article publishing date)
but 'lastvisitDate' is always almost current time because this user just logged in and Joomla functionality update lastvistDate in the moment of user log in.

2. I was thinking about different approach. Changing in the core (I know not a good way) that Joomla will update lastvisitDate on log out but then realized that almost all users never logged out (they just closing their web browser).

3. I was thinking about to use cookie mechanism but it have its own week point. It will be dependent on what computer user was using and last but not least it is little bit complicated for my PHP/Joomla app skills.

4. I was thinking about adding new field in users table. Write a plugin which will be save to this filed lastvisitDate before Joomla is overwriting this date with current user login date. It is complicated, I do not know what impact for future Joomla updates will this change have in database. I do not know what event tiger should I use to fire this plugin to be faster then Joomla core functionality with its overwriting lastvisitDate.
So it seems most complicated form all ideas.

Do you have any idea how to deal with this?

Best regards
Arek

User avatar
lefteriskavadas
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 101
Joined: Fri Feb 05, 2016 6:10 pm
Location: Athens, Greece
Contact:

Re: Finding a way to mark articles published after last user visit

Post by lefteriskavadas » Mon Sep 17, 2018 9:21 am

Hi,

First, of all do not hack the core. You will get locked out of updates. You need a custom plugin for this. You also need a custom table to keep the last login date for each user.

Regards
Joomla Extensions https://www.firecoders.com/

User avatar
effrit
Joomla! Guru
Joomla! Guru
Posts: 846
Joined: Sun Nov 12, 2017 2:21 pm
Location: middle of Russia
Contact:

Re: Finding a way to mark articles published after last user visit

Post by effrit » Mon Sep 17, 2018 9:29 am

Hi. I am not a programmer, but i guess you mast make 2 user plugin for onUserLogout and onUserLogin
https://docs.joomla.org/Plugin/Events/User#onUserLogout
and write both date in custom table.

arek1
Joomla! Apprentice
Joomla! Apprentice
Posts: 24
Joined: Sun Jul 29, 2007 6:06 pm

Re: Finding a way to mark articles published after last user visit

Post by arek1 » Mon Sep 17, 2018 10:44 am

Thank you both.
It seems that only solution 4 is a way to go.

User avatar
lefteriskavadas
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 101
Joined: Fri Feb 05, 2016 6:10 pm
Location: Athens, Greece
Contact:

Re: Finding a way to mark articles published after last user visit

Post by lefteriskavadas » Mon Sep 17, 2018 10:46 am

Solution 4 is the way to go, but with a custom table. Do not modify the core users table.

Regards
Joomla Extensions https://www.firecoders.com/

arek1
Joomla! Apprentice
Joomla! Apprentice
Posts: 24
Joined: Sun Jul 29, 2007 6:06 pm

Re: Finding a way to mark articles published after last user visit

Post by arek1 » Mon Sep 17, 2018 11:00 am

As I found in documentation lastvisitDate is updated on event onUserLogin. What event will be the best to trigger my own plugin which will be copying lastvisitDate to my custom table fo future use? It should be some event which is triggered just before onUserLogin. Is onUserAuthorisation good event?


Locked

Return to “Joomla! 3.x Coding”