• twitter image
  • facebook image
  • youtube image
  • linkedin image
Language: CMS Made Simple Czech CMS Made Simple France CMS Made Simple Spain CMS Made Simple Hungary CMS Made Simple Russia CMS Made Simple Netherlands

All times are UTC




Post new topic Reply to topic  [ 12 posts ] 
Author Message
 Post subject: FEU Redirect to last page after login [SOLVED]
PostPosted: Tue Nov 16, 2010 2:53 am 
Offline
Forum Members
Forum Members

Joined: Tue Feb 02, 2010 5:02 am
Posts: 21
Hi everyone.  I have a 1.8.2 site with the latest FEU installed.  It's working great, though we have one issue that is really getting in the way of a good user experience.

On our site, we have a whole section that is protected and requires login.  We don't have the login form on all the pages since we don't want to figure it so prominently.  So upon clicking a link to any protected page (or being directed there from an email or other site), we have the normal code to redirect the user to login before they can see the protected content.  Here's the redirect code:

Code:
    {if !$ccuser->loggedin() || ($ccuser->loggedin() && !$ccuser->memberof('Approved Members'))}
       {redirect_page page='member-login'}
    {/if}


The redirect_page tag works fine.  Once the user logs in, the FEU setting I have in place to redirect them to a specific page, works fine.  But in nearly every case, the user wants a different page than the one I have set up.

I've read a few posts related to this, but none have a definitive solution that would allow the redirect to bring them back to the page they originally wanted, post-login.  I've tried adding a "from" attribute to the redirect_page command, with and without the "redirect after login" FEU setting being set, but it just doesn't work.  I've also tried putting some code in to save the page alias so I could use it for the redirect after login setting, without success.

Would greatly appreciate any help with this; I'm an admitted newbie with PHP and Smarty (I'm much more comfortable in the .NET/C# world).  Thank you in advance!

Erik


Last edited by ESBertrand on Wed Nov 17, 2010 4:32 am, edited 1 time in total.

Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: FEU Redirect to last page after login
PostPosted: Tue Nov 16, 2010 3:47 am 
Offline
Power Poster
Power Poster

Joined: Mon Jun 12, 2006 9:02 pm
Posts: 1900
there is probably a more elegant way, but I think this would work:

on the protected page, use a UDT or Smarty to create a session variable to hold the HTTP_REFERER when the user arrives at that page (before he/she is immediately redirected).

after successful login, do one of two things: either call a UDT using an event, or redirect to a "redirect-after-login" page.  With either of these options (UDT would use PHP, redirect page would use Smarty), retrieve the session variable you created above, and redirect to it.

i.e. if you use the "redirect-after-login" page, it would be very simple and would look something like:
{redirect_page page=$smarty.session.referring_page}  This would redirect to the page that was originally requested, prior to the user being redirected to the first redirect page which took him to the login page...  make sense?


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: FEU Redirect to last page after login
PostPosted: Tue Nov 16, 2010 5:12 am 
Offline
Dev Team Member
Dev Team Member
User avatar

Joined: Tue Oct 19, 2004 6:44 pm
Posts: 8158
Location: Fernie British Columbia, Canada
1. On each protected page:
Code:
{if !$ccuser->loggedin()}
   {session_put var='last_page' value=$page_alias}
   {redirect_page page='login'}
{/if}


2. Create a new gcb named return_last like this:
Code:
{if isset($smarty.session.last_page)}
  {$smarty.session.last_page}
  {session_erase var='last_page'}
{/if}


3. In the FEU preferences:  "Page to Redirect to After Login" enter this:
Code:
{global_content name='return_last'}


I may not have the syntax exactly correct,  I'm going from memory.  I have done this about 3 times already.

You will need the CGSimpleSmarty module.

_________________
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: FEU Redirect to last page after login
PostPosted: Tue Nov 16, 2010 1:18 pm 
Offline
Forum Members
Forum Members

Joined: Tue Feb 02, 2010 5:02 am
Posts: 21
Thanks so much, CalGuy.  I set this up and it does seem to be saving the page alias through login, but when I click Login, the page is returned without stylesheets, and includes the error:

couldn't get pageid for
audio-video-protected

This tells me the page alias is remembered -- it is the alias of the protected page I originally requested -- but it looks like it cannot translate it into an ID.  I'll troubleshoot the error, but would welcome any input you might have on it, too.

Erik


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: FEU Redirect to last page after login
PostPosted: Tue Nov 16, 2010 1:43 pm 
Offline
Power Poster
Power Poster

Joined: Mon Jun 12, 2006 9:02 pm
Posts: 1900
calguy1000 wrote:
1. On each protected page:
Code:
{if !$ccuser->loggedin()}
   {session_put var='last_page' value=$page_alias}
   {redirect_page page='login'}
{/if}


2. Create a new gcb named return_last like this:
Code:
{if isset($smarty.session.last_page)}
  {$smarty.session.last_page}
  {session_erase var='last_page'}
{/if}


3. In the FEU preferences:  "Page to Redirect to After Login" enter this:
Code:
{global_content name='return_last'}


I may not have the syntax exactly correct,  I'm going from memory.  I have done this about 3 times already.

You will need the CGSimpleSmarty module.



...and there is the more elegant method I mentioned ;-)


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: FEU Redirect to last page after login
PostPosted: Tue Nov 16, 2010 2:45 pm 
Offline
Forum Members
Forum Members

Joined: Tue Feb 02, 2010 5:02 am
Posts: 21
I certainly didn't want to downplay your response, jmcgin51.  I kind of jumped on CalGuy's post since it had ready-made code to plug in.  It is basically what you suggested, in any case, except for the global content block part.  And, since I'm a PHP and Smarty novice, and I've already spent a couple of hours researching this, I wanted to give the code a try.

Thanks a bunch for taking the time to help out - I really appreciate it.

Erik


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: FEU Redirect to last page after login
PostPosted: Tue Nov 16, 2010 3:03 pm 
Offline
Power Poster
Power Poster

Joined: Mon Jun 12, 2006 9:02 pm
Posts: 1900
no problem at all.  I just reread my last post and realized it probably didn't come across as I intended.  I was trying to quote Calguy and then say "THERE (Calguy's solution) is the more elegant solution that I said was probably out there somewhere".  Instead I made it look like I thought my solution was more elegant... :-[  oh well...  whatever works


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: FEU Redirect to last page after login
PostPosted: Wed Nov 17, 2010 4:31 am 
Offline
Forum Members
Forum Members

Joined: Tue Feb 02, 2010 5:02 am
Posts: 21
One very happy guy here.  :D

I figured out what was causing the "Couldn't find pageid xxxx" error!

The global content block (GCB) needs to return only the alias of the original page, without any spaces or other markup before or after it.  Since I had pasted the global content block code in "design" mode, a few extra spaces and BR tags were included in the GCB's return value.  This was throwing off FEU, rightly so.

In the end, I found I had to remove all spaces, and even line breaks, from the code within the GCB.  So the final modified GCB code I have from CalGuy's suggestion is:

Code:
{if isset($smarty.session.last_page)}{$smarty.session.last_page}{session_erase var='last_page'}{/if}


Simply put all the smarty commands on one line, with no spaces or hard returns between each.  With this in place, the redirects are now working flawlessly.  Thanks so, so much to CalGuy1000 and jmcgin51 for the help!

This should definitely be documented somewhere other than a lowly forum post, so others can benefit.

Erik


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: FEU Redirect to last page after login [SOLVED]
PostPosted: Wed Nov 17, 2010 3:27 pm 
Offline
Forum Members
Forum Members

Joined: Sun Dec 14, 2008 4:54 am
Posts: 80
hi,
sorry to be dense, but in step 3, you say
Quote:
In the FEU preferences:  "Page to Redirect to After Login" enter this:

when I go to users&groups - Frontend User Management - Preferences....i don't see an option to 'redirect'...am I looking in the wrong spot?

thanks


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: FEU Redirect to last page after login [SOLVED]
PostPosted: Wed Nov 17, 2010 3:46 pm 
Offline
Forum Members
Forum Members

Joined: Sun Dec 14, 2008 4:54 am
Posts: 80
ok, i found it

it is in

users&groups - Frontend User Management - builtin authentication

thanks


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: FEU Redirect to last page after login [SOLVED]
PostPosted: Sat Jan 07, 2012 11:15 pm 
Offline
Power Poster
Power Poster

Joined: Sat Jan 15, 2011 8:36 am
Posts: 695
Location: Western Australia
Finally arrived at this post after much searching - solution works perfectly!

Thanks to all!


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: FEU Redirect to last page after login [SOLVED]
PostPosted: Mon Jul 23, 2012 10:44 am 
Offline
Forum Members
Forum Members

Joined: Sun Sep 20, 2009 10:42 pm
Posts: 17
Location: Portsmouth, UK
Hi all

Just wondering if this is possible...

Calguy's code above works great, but what I need is to be able to redirect to a news detail page, which isn't possible because the FEU module only accepts page ID/alias for post-login redirect.

Has anyone ever found a solution or method for doing this? Since FEU only allows you to use a page ID or alias it leaves you a bit stuck if you wanted to redirect to a dynamic page such as news/blog detail page.

Any advice much appreciated!

Steve


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 12 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users


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

Search for:
Jump to:  
Hosting Nation - Managed CMSMS Hosting