On a new visit redirect users to home page

General questions relating to Joomla! 3.x.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting.
Forum Post Assistant - If you are serious about wanting help, you should use this tool to help you post.
Windows Defender SmartScreen Issues <-- please read this if using Windows 10
Locked
doug__j
Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Wed Jul 21, 2021 9:21 pm

On a new visit redirect users to home page

Post by doug__j » Wed Jul 21, 2021 9:33 pm

I have a web site with a home page with links to pages one and two. If someone bookmarks page two they go direct to page two missing the new content on the home page

I would like to redirect them to the home page if they go direct to page two.

Any suggestions
Doug

sozzled
I've been banned!
Posts: 13639
Joined: Sun Jul 05, 2009 3:30 am
Location: Canberra, Australia

Re: On a new visit redirect users to home page

Post by sozzled » Wed Jul 21, 2021 9:51 pm

Interesting question.

I don't think there's a built-in way in J! to control this behaviour but it's possible to address the matter by using cookies.

Let's say a user visits the home page. You could generate a session cookie when that happens. Then, if a person visits "page two" you could see if the session cookie exists and allow the access to "page two". If someone has bookmarked "page two" and goes there directly, when you check if the session cookie exists for the home page—and it won't exist—then you could redirect the user to the home page (and then the session cookie will be generated and then they can go to "page two").

You could write a piece of Javascript to generate the cookie on the home page and another piece of Javascript for "page two" to check if the "home page cookie" exists and conditionally redirect the browser to the home page.

That would be how I would do this. Someone else may have another (or different) approach. Good luck. :)

User avatar
Webdongle
Joomla! Master
Joomla! Master
Posts: 44070
Joined: Sat Apr 05, 2008 9:58 pm

Re: On a new visit redirect users to home page

Post by Webdongle » Thu Jul 22, 2021 2:09 am

Yep there has to be a method that recognises page 2 has been visited.

Tricky part is when they get back to page 1 they will not be able to reach page two again

A cookie would do it but it would need to know when new unread content was on page 1. And only redirect when there was new content.
http://www.weblinksonline.co.uk/
https://www.weblinksonline.co.uk/updating-joomla.html
"When I'm right no one remembers but when I'm wrong no one forgets".

KianWilliam
Joomla! Guru
Joomla! Guru
Posts: 561
Joined: Thu Jan 12, 2017 10:13 am

Re: On a new visit redirect users to home page

Post by KianWilliam » Thu Jul 22, 2021 2:23 pm

I have promised Toivo not to post any message but I found this question interesting, that is why for the last time I shall post. Session variable method is an excellent way, yet in case we may be able to use:
history.length or document.referrer in javascript and take the logical action after that. About the change of content, we may be able to enable article archive in such a way that after each update, the previous version is to be kept, then with a database checking for the existence of the archive article the logical action could be pursued.
We even could employ the last visit time of the user (if the user is registered) and compare it with the update time of the article to be more exact about the next logical action to redirect or not to redirect the user.
The whole stuff could be placed in a content plugin or just in the template or layout override of the content.
This way we will be able to keep only one archive and delete the rest of the archives based on the actual logic. I have never done it before , I thought about it as I read it that is why I used the term maybe.
[ redacted ]
Last edited by toivo on Fri Jul 23, 2021 4:03 am, edited 1 time in total.
Reason: mod note: manual signature not allowed - forum rules available from https://forum.joomla.org/viewtopic.php?f=8&t=65


Locked

Return to “General Questions/New to Joomla! 3.x”