The Joomla! Forum ™



Forum rules


Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.



Post new topic Reply to topic  [ 76 posts ]  Go to page 1, 2, 3  Next
Author Message
PostPosted: Tue Mar 10, 2009 1:45 am 
Joomla! Apprentice
Joomla! Apprentice

Joined: Fri Mar 06, 2009 3:43 pm
Posts: 10
I wanted to share this with the joomla community. When members visit an article when not logged in they get the very unhelpful 403 access restricted page. Its an easy template modification to move them to the login screen, but then they don't end up at the article they wanted when they login.

Here are step by step instruction on how to modify your default 1.5.9 joomla install to longin members and then send them to the page they requested.

I fumbled through most of it, so the code could probably be improved. If you can improve it, Post it here! Hopefully joomla will incorporate something like this into its default install.

First. Modify the /templates/system/error.php.

Find the line:
Quote:
defined( '_JEXEC' ) or die( 'Restricted access' );


and the place the following code after the code above:

Quote:
$ReferTo = $_SERVER['REQUEST_URI'];
$ReferTo = base64_encode($ReferTo);

if ($this->error->code = '403') {
header('Location:index.php?option=com_user&view=login&ReferTo='.$ReferTo); die();
}


Second. Modify the /components/com_user/views/login/tmpl/default_login.php

Search for:
Quote:
<input type="hidden" name="return" value="<?php echo $this->return; ?>" />


And replace it with:
Quote:
<input type="hidden" name="return" value="<?php if ($_GET['ReferTo']) echo $_GET['ReferTo']; else echo $this->return; ?>" />


There you have it. You should be all modified! I have included the 2 files in this message, so you can just overwrite the last ones as well. It might be easier then opening and modifying the code. But beware you are using the same version of joomla. ONLY modify the code yourself if you are using a different version.

Dr. Sassafras


You do not have the required permissions to view the files attached to this post.


Top
 Profile  
 
PostPosted: Sun Mar 29, 2009 11:35 pm 
Joomla! Fledgling
Joomla! Fledgling

Joined: Sun Mar 29, 2009 11:02 pm
Posts: 3
Wow, your post is very helpful. I made the change and it works great.
Thanks for your sharing.


Top
 Profile  
 
PostPosted: Mon Mar 30, 2009 12:36 am 
User avatar
Joomla! Master
Joomla! Master

Joined: Sat Apr 05, 2008 9:58 pm
Posts: 23363
Location: @Webdongle
Is removing
Quote:
defined( '_JEXEC' ) or die( 'Restricted access' );
such a good ides ?

It is put on Joomla files for a reason.

My mistake, just re-read it, i think i will need to lay off the booz before i read the posts. :-[

_________________
http://weblinksonline.co.uk/joomla-faq.html


Last edited by Webdongle on Mon Mar 30, 2009 2:23 pm, edited 1 time in total.

Top
 Profile  
 
PostPosted: Mon Mar 30, 2009 1:22 am 
Joomla! Apprentice
Joomla! Apprentice

Joined: Thu Mar 05, 2009 8:18 pm
Posts: 9
I have been struggling with this issue for weeks and your simple solution fixed it for me in minutes. Thank you very much.


Top
 Profile  
 
PostPosted: Mon Mar 30, 2009 11:43 am 
Joomla! Apprentice
Joomla! Apprentice

Joined: Fri Mar 06, 2009 3:43 pm
Posts: 10
Webdongle wrote:
Is removing
Quote:
defined( '_JEXEC' ) or die( 'Restricted access' );
such a good ides ?\


Please read the instructions more closely. I specify putting the code after this line. Removing the code would allow this file to be called without being logged in... Now if it was a public access file, then I don't see the problem in it... But I am not really an expert and its all sort of off topic anyhow. Yes. Don't remove the code.


Top
 Profile  
 
PostPosted: Mon Mar 30, 2009 12:24 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Fri Mar 06, 2009 3:43 pm
Posts: 10
PastorAarn wrote:
I have been struggling with this issue for weeks and your simple solution fixed it for me in minutes. Thank you very much.


Yes, it took me the better part of a day to figure out how to do this. Glad I can save other people some time.

On another note, I just took at look at the upgrade package from joomla 1.5.9 to 1.5.10. The files we are working with here do not appear to be changed in 1.5.10. So, the instructions and the upgrade files should both work for 1.5.10 as well as 1.5.9.

Now, to be phenomenological about this, we need to see the file overwrites in action in order to be sure. If anyone can confirm that the files posted here do in fact work in 1.5.10, I am sure there would be other people who would appreciate the confirmation.


Top
 Profile  
 
PostPosted: Tue Mar 31, 2009 2:23 am 
User avatar
Joomla! Master
Joomla! Master

Joined: Mon Aug 29, 2005 10:17 am
Posts: 12065
Location: Netherlands/ UK/ S'pore/Jakarta/ North America
Webdongle wrote:
My mistake, just re-read it, i think i will need to lay off the booz before i read the posts.
Sounds like a plan to me! 8)

_________________
--- Joomla Professional Support Services :: http://gws-desk.com ---
--- Joomla Professional and Specialized Hosting :: http://gws-host.com ---
--- Ready to Roll Joomla! Web Sites : 1 - 7 days only! :: @ gws-market.com ---


Top
 Profile  
 
PostPosted: Wed Apr 01, 2009 8:43 pm 
Joomla! Fledgling
Joomla! Fledgling

Joined: Wed Apr 01, 2009 2:36 pm
Posts: 1
Hi,

Thank you very much drsassafras, the solution is great ;D
I did upgrade to 1.5.10 today and it looks it works as well.

Best regards,
Izabela


Top
 Profile  
 
PostPosted: Sun Apr 19, 2009 5:43 pm 
Joomla! Fledgling
Joomla! Fledgling

Joined: Fri Jul 04, 2008 5:32 pm
Posts: 4
Is there a way to do this when using community builder?


Top
 Profile  
 
PostPosted: Thu Apr 30, 2009 2:08 pm 
Joomla! Fledgling
Joomla! Fledgling

Joined: Thu Nov 27, 2008 10:59 pm
Posts: 4
Just tried this with J1.5.10 and CB1.2 and it did not work. Worth a try though.


Top
 Profile  
 
PostPosted: Tue Jun 09, 2009 4:58 am 
Joomla! Apprentice
Joomla! Apprentice

Joined: Thu May 21, 2009 3:53 am
Posts: 23
With the helpful hints that I get at this forum I will never really learn Joomla or PHP...
This "small" change really makes a difference. It makes my amateur page seem much more professional. A visitor can save a page to his favorites and later just click it - sign in and go right to the page. Just like a real web page! lol - thanks.


Top
 Profile  
 
PostPosted: Fri Jun 12, 2009 12:10 pm 
User avatar
Joomla! Enthusiast
Joomla! Enthusiast

Joined: Sat Apr 18, 2009 9:38 pm
Posts: 140
Location: UK
Thanks. I posted similar problem several months ago without help. until a member posted this link. I will give it a try.

_________________
http://www.hoodiadietworks.com | http://www.findiet.com


Top
 Profile  
 
PostPosted: Wed Jun 17, 2009 3:37 pm 
Joomla! Enthusiast
Joomla! Enthusiast

Joined: Thu Jan 22, 2009 4:10 pm
Posts: 112
Very good! I haven't thoroughly tested it but it worked the first time. Thank you.

Can't believe this is not a default thing here.

_________________
http://www.xtremeopensource.com


Top
 Profile  
 
PostPosted: Fri Jul 17, 2009 8:33 pm 
Joomla! Intern
Joomla! Intern

Joined: Fri Feb 27, 2009 9:27 am
Posts: 90
this nice sharing has been long time but it very helpfull, thank you very much :D

_________________
http://id.intogsm.com
http://www.intogsm.com


Top
 Profile  
 
PostPosted: Thu Aug 06, 2009 1:30 am 
Joomla! Explorer
Joomla! Explorer

Joined: Sun Sep 02, 2007 12:50 am
Posts: 361
i will try it now
it seems like a solution

_________________
http://www.neocrisis.com/ - What will you find Next?


Top
 Profile  
 
PostPosted: Thu Aug 06, 2009 2:44 am 
Joomla! Explorer
Joomla! Explorer

Joined: Sun Sep 02, 2007 12:50 am
Posts: 361
um have the latest Joomla 1.5.13
and i dont c
components/com_user/views/login/tmpl/default_login.php

any ideas?

also about part one of directions
i think that the link to login is different now
for my site its

http://www.neocrisis.com/component/comprofiler/login
i dont know its the same or not

_________________
http://www.neocrisis.com/ - What will you find Next?


Top
 Profile  
 
PostPosted: Thu Aug 20, 2009 3:40 am 
Joomla! Apprentice
Joomla! Apprentice

Joined: Wed Aug 19, 2009 7:07 pm
Posts: 9
Wow, this worked, thanks so much!

RANT: It's REDICULOUS that a product this mature does not do this by default! It's utterly absurd that I have to hack the code to make this behave the way it should!!!!!


Top
 Profile  
 
PostPosted: Thu Aug 20, 2009 4:10 am 
Joomla! Explorer
Joomla! Explorer

Joined: Sun Sep 02, 2007 12:50 am
Posts: 361
jazzking2001 wrote:
um have the latest Joomla 1.5.13
and i dont c
components/com_user/views/login/tmpl/default_login.php

any ideas?

also about part one of directions
i think that the link to login is different now
for my site its

http://www.neocrisis.com/component/comprofiler/login
i dont know its the same or not

any idea?

_________________
http://www.neocrisis.com/ - What will you find Next?


Top
 Profile  
 
PostPosted: Mon Sep 28, 2009 11:20 am 
Joomla! Fledgling
Joomla! Fledgling

Joined: Tue Sep 22, 2009 5:57 am
Posts: 4
Most awesome posting and it did exactly what I wanted it to do.

One further question, is there anyway to make the login form popup in front of the (blacked out) page they were on trying to access the restricted link from? to look something like this:
Image

Thanks for a great solution!


Top
 Profile  
 
PostPosted: Fri Oct 09, 2009 2:35 pm 
Joomla! Fledgling
Joomla! Fledgling

Joined: Fri Oct 09, 2009 2:25 pm
Posts: 1
Great post! I'm using 1.5.14 and the redirect goes to the login page as it should but it returns to the home page rather than the requested page. Any ideas on how I can get it to go to the requested page rather than the home page?


Top
 Profile  
 
PostPosted: Sat Oct 31, 2009 2:07 am 
Joomla! Intern
Joomla! Intern

Joined: Thu Oct 23, 2008 10:59 am
Posts: 81
Generator11, o2plus2h:

I made it work with Community Builder. I think I have 1.2 Stable.
Running Joomal Version 1.5.14

Upload the Error file in /templates/system - File still the same no change with this version

Change

if ($this->error->code = '403') {
header('Location:index.php?option=com_user&view=login&ReferTo='.$ReferTo); die();
}

if ($this->error->code = '403') {
header('Location:index.php?option=com_comprofiler&task=login&ReferTo='.$ReferTo); die();

Wow, this stuff is starting to make sense to me.
If someone can post this in CB forums that would be great.

Joomla rocks!
Thanks drsassafras for getting it started!


Tim


Top
 Profile  
 
PostPosted: Sat Oct 31, 2009 6:13 pm 
User avatar
Joomla! Master
Joomla! Master

Joined: Sat Apr 05, 2008 9:58 pm
Posts: 23363
Location: @Webdongle
sw373 wrote:
Great post! I'm using 1.5.14 and the redirect goes to the login page as it should but it returns to the home page rather than the requested page. Any ideas on how I can get it to go to the requested page rather than the home page?


Try making the Menu Item to the page Reistered ?

_________________
http://weblinksonline.co.uk/joomla-faq.html


Top
 Profile  
 
PostPosted: Sun Nov 01, 2009 8:21 am 
Joomla! Explorer
Joomla! Explorer

Joined: Sun Sep 02, 2007 12:50 am
Posts: 361
what file do we need to edit?
i am looking at templates/system/error.php but that page is for when page links do not work ect

_________________
http://www.neocrisis.com/ - What will you find Next?


Top
 Profile  
 
PostPosted: Sun Nov 01, 2009 10:55 am 
Joomla! Fledgling
Joomla! Fledgling

Joined: Tue Sep 22, 2009 5:57 am
Posts: 4
jazzking2001 wrote:
what file do we need to edit?
i am looking at templates/system/error.php but that page is for when page links do not work ect


jazzking, the instructions are very clear and if you follow exactly what drsassafras says it works. 403 is an error, its a link that cannot be accessed unless you have the correct privledges. If you're not wanting what this post instructs then you should look elsewhere or post what you are really looking for but this does exactly what it says!


Top
 Profile  
 
PostPosted: Sun Nov 08, 2009 3:41 pm 
Joomla! Fledgling
Joomla! Fledgling

Joined: Wed Jul 29, 2009 9:45 am
Posts: 1
zoomlanski: worked well for CB ... just don't forget the "}" at the end

... however, after the log-in I get directed to the front page and not to the article .. any ideas?


Top
 Profile  
 
PostPosted: Sat Nov 21, 2009 4:08 pm 
Joomla! Fledgling
Joomla! Fledgling

Joined: Sat Nov 21, 2009 4:04 pm
Posts: 2
Can't make it work in version 1.5.14 (with no CB installed)

Can anyone offer asistance?

Thanks.

.............................................

Update, I disbled "Search Engine Friendly URLs" and it now redirects to the homepage. Not ideal as I would prefer search engine friendly URLs.

Any thoughts anyone ... thanks.


Top
 Profile  
 
PostPosted: Sat Nov 21, 2009 8:50 pm 
User avatar
Joomla! Master
Joomla! Master

Joined: Sat Apr 05, 2008 9:58 pm
Posts: 23363
Location: @Webdongle
There is an alternative...

* Create a separate menu that is not Activated.
* In that menu place a link to the page that is members only and set it Registered.
* In your main menu place a link to the link in the inactive menu and leave it set Public.

The users will see the link in your main menu. When that link is clicked by non logged in members the 'Please login..' will be displayed. After logging in the user will be directed to the target page.

_________________
http://weblinksonline.co.uk/joomla-faq.html


Top
 Profile  
 
PostPosted: Sun Nov 22, 2009 9:41 am 
Joomla! Fledgling
Joomla! Fledgling

Joined: Sat Nov 21, 2009 4:04 pm
Posts: 2
Thanks Webdongle,
Eventually got there. I initially used "Alias" on the wrong menu. All sorted now ... thanks again.


Top
 Profile  
 
PostPosted: Fri Nov 27, 2009 4:50 pm 
Joomla! Intern
Joomla! Intern

Joined: Fri Feb 27, 2009 9:27 am
Posts: 90
Hello,

I know my problem may be different from the cases above, but please help.
Is it possible to the default joomla login to be redirect to https? and if can be please any one help me... :( :-\
because I have tried using module parameters in the login does not work for specific login page only, because after redirected to https all the links changed to https.

Thanks,

_________________
http://id.intogsm.com
http://www.intogsm.com


Top
 Profile  
 
PostPosted: Fri Nov 27, 2009 5:27 pm 
User avatar
Joomla! Master
Joomla! Master

Joined: Sat Apr 05, 2008 9:58 pm
Posts: 23363
Location: @Webdongle
a2purn wrote:
Hello,

I know my problem may be different from the cases above, but please help.
Is it possible to the default joomla login to be redirect to https? and if can be please any one help me... :( :-\
because I have tried using module parameters in the login does not work for specific login page only, because after redirected to https all the links changed to https.

Thanks,

Do you have SSL ?

_________________
http://weblinksonline.co.uk/joomla-faq.html


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 76 posts ]  Go to page 1, 2, 3  Next



Who is online

Users browsing this forum: No registered users and 15 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group