Front End Users module - redirect to last page

Do something cool with CMS? Show us ...
This board is for 'Answers', and the discussion of answers... Not for questions.
Post Reply
gap_tooth_clan

Front End Users module - redirect to last page

Post by gap_tooth_clan »

If you are using FEU module and you need to redirect back to the page where a user was prior to being redirected to login use this tag

call it from your template with {Redirection myPageAlias="$page_alias"}

Make a UDT with a name Redirection

Code: Select all

if ($_SESSION['last_page'] == ''){
  $_SESSION['last_page_2'] = 'home';
} else {
  $_SESSION['last_page_2'] = $_SESSION['last_page'];
}

if ($_SESSION['current_page'] == ''){
  $_SESSION['last_page'] = 'home';
} else {
  $_SESSION['last_page'] = $_SESSION['current_page'];
}

$_SESSION['current_page'] = $params['myPageAlias'];

$smarty->assign('last_page_2', $_SESSION['last_page_2']);
and on the preferences tab for FEU set the redirect to page after login field to {$last_page_2}

job done
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm
Location: Fernie British Columbia, Canada

Re: Front End Users module - redirect to last page

Post by calguy1000 »

FEU has this capability built in.
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.
rvaneerd

Re: Front End Users module - redirect to last page

Post by rvaneerd »

hi CalGuy,
calguy1000 wrote: FEU has this capability built in.
??? Can you please explain / point me in the right direction where this can be realized?
I scanned all settings / preferences of the FEU but couldn't find it  :-[

Regards,
Rob
kissack
Forum Members
Forum Members
Posts: 18
Joined: Mon Oct 22, 2007 6:10 pm

Re: Front End Users module - redirect to last page

Post by kissack »

rvaneerd wrote: hi CalGuy,
calguy1000 wrote: FEU has this capability built in.
??? Can you please explain / point me in the right direction where this can be realized?
I scanned all settings / preferences of the FEU but couldn't find it  :-[

Regards,
Rob
I cant find it either :-(
ESBertrand
Forum Members
Forum Members
Posts: 21
Joined: Tue Feb 02, 2010 5:02 am

Re: Front End Users module - redirect to last page

Post by ESBertrand »

From what I see, this is not built-in to FEU - at least not in the latest FEU I have (version 1.12.5).  I tried not setting the "redirect after login" value, which seemed the most logical default behavior.

CalGuy - if this is built-in, could you let us know how to enable this behavior?  Without an automatic redirect after login back to the page the user requested, the UX is greatly diminished.

Currently, we have this code just after the starting BODY tag in our template (got it from the FEU docs, I believe):

Code: Select all

{if !$ccuser->loggedin() || ($ccuser->loggedin() && !$ccuser->memberof('Approved Members'))}{redirect_page page='member-login'}{/if}
I'm going to try to work gap_tooth_clan's suggestion into this.

Erik
Peciura

Re: Front End Users module - redirect to last page

Post by Peciura »

My login form is always visible and user after login/logout is redirected to a page visited just before login/logout procedure.

Users & Groups » Frontend User Management > Builtin Authentication > Redirection Settings
paste {$page_alias} to fields
"PageID/Alias to jump to after login" and
"PageID/Alias to jump to after logout"
ESBertrand
Forum Members
Forum Members
Posts: 21
Joined: Tue Feb 02, 2010 5:02 am

Re: Front End Users module - redirect to last page

Post by ESBertrand »

Thanks for the reply, Peciura.  Your method works because you have the login fields on every single page.  We're not doing that since we don't want to figure the login so prominently.

If anyone else is doing this with just a single login page (hence the need for redirection back to the originally-requested page), please post!

Erik
ESBertrand
Forum Members
Forum Members
Posts: 21
Joined: Tue Feb 02, 2010 5:02 am

Re: Front End Users module - redirect to last page

Post by ESBertrand »

I've tried to get this to work by setting a session variable via PHP, but no go so far.  Doesn't help that I'm a .NET developer working in a PHP/Smarty world...  anyone have any tips?

Am I right that this should be workable simply by doing the following:

1.  Add code to the "secure page" template to save the page alias (the value of the "page" querystring variable) to a session variable.  Something like this:

Code: Select all

{$_SESSION['LastPage'] = $params['page']}
2.  Add code to the page that hosts the login form, that will set a smarty variable with the value of the session variable set in step 1, like this:

Code: Select all

{$smarty->assign('DestPage', $_SESSION['LastPage'])}
3.  Set the "redirect after login" setting within FEU to the smarty variable set in step 2 (i.e. $DestPage)

I'm getting smarty errors with at least step 2, and probably step 1, too (there's a redirect that follows the listed line, so I'm probably just not seeing that error).  Any suggestions?  Help!

Erik
Peciura

Re: Front End Users module - redirect to last page

Post by Peciura »

Idea is to save page alias of any visited page but login page. Make sure module CGSimpleSmarty is installed.
{if $page_alias!='login_page_alias'}
{session_put var='saved_alias' value=$page_alias}
{/if}
Paste
{$smarty.session.saved_alias}
to fields
"PageID/Alias to jump to after login" and
"PageID/Alias to jump to after logout".

Additionally specify default page if for some reasons page alias was not saved to session.
{$smarty.session.saved_alias|default:'default_alias'}
Last edited by Peciura on Tue Nov 16, 2010 10:10 am, edited 1 time in total.
Post Reply

Return to “Tips and Tricks”