Handy FEU Sign-in-Page that Returns You to the Original Page

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

Handy FEU Sign-in-Page that Returns You to the Original Page

Post by kendo451 »

If you run a membership site, it is not uncommon for members to forget to log in and then try to access a membership-only feature on the site.  On many pages there is room to show them a sign-in form in place of the page content, in which case you would put something like this as the page content (in a global content block to protect the -> from the WYSIWYG).

Code: Select all

{content assign='thiscontent'}
{if $ccuser->loggedin() && $ccuser->memberof('Members')}
<!-- Show Member Content Here -->
{$thiscontent}
{else}
{cms_module module='FrontEndUsers' returnto=$page_alias}
{/if}
This will always return the user to the page they tried to view.

But in some cases, such as a page that is intended to be viewed by both the unsigned in public and members, there is not room to do that, so a sign-in button that returns you to the original page when you're finished can be handy.

First create a page called sign-in and put this in your page content:

Code: Select all

 {* This sign in page will return the user to the
	page alias in the $smarty.get.returnto *}
{if $smarty.get.returnto} 
     {cms_module module='FrontEndUsers' returnto=$smarty.get.returnto} 
{else} 
     {cms_module module='FrontEndUsers' returnto='home'} 
{/if}
Next, create a global content block called sign_in_button and put something like this in there:

Code: Select all

{* GCB sign_in_button *}
{* This will make a button that will send the user to a sign in page that
   will return the user to this page when finished. *}
   
<a href="http://yourdomain.com/index.php?page=sign-in&returnto={$page_alias}">Sign In</a>
I use this sign-in-button in place of a button that performs an action for logged in members.  In this case for a golf tour, where if the user is logged in we let them register for a tournament, and if they are logged out we send them to the sign-in.

Code: Select all

{if $ccuser->loggedin() && $ccuser->memberof('Members')}
{cms_selflink page='tournament-registration' text='Sign Up'}
{else}
{global_content name='sign_in_button'}
{/if}
It is true that this is not a pretty URL, but you don't want the Sign In page to be indexed anyway, so it doesn't matter.
Last edited by kendo451 on Wed Aug 26, 2009 1:07 pm, edited 1 time in total.
Post Reply

Return to “Tips and Tricks”