Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Smarty Login Integration

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
rootseire
Smarty Rookie


Joined: 11 Feb 2008
Posts: 11

PostPosted: Wed Feb 13, 2008 12:52 pm    Post subject: Smarty Login Integration Reply with quote

Hi,
I have a site built using smarty, and i also have a separate php login script, both smarty and php are using sessions. I want to integrate the php script with the site so that:

When the user visits the site but is not logged in, and tries to add an item to the online shopping cart, they are redirected to the register page.

And also when the user is logged in, they may use the online shop throughout the site.

Is there some lines of code that i could write in the tpl file to say:

if the user is logged in, show the add to cart button, and
if they are not logged in, show a link to sign up?

On the other hand, if there was help available to get a Smarty based login script up and running, i would be very grateful if anyone could help.

Thanks in advance,
Pat
Back to top
View user's profile Send private message
kent.fallman
Smarty Rookie


Joined: 12 Feb 2008
Posts: 5

PostPosted: Wed Feb 13, 2008 2:26 pm    Post subject: Reply with quote

im experimenting with some login pages right now .. you could let a vars value decide what to show
Code:
{include file="header.html" title="Login"}

<h2>{$form_header}</h2>

{if $form_error == "yes"}
   <p>{$error_message}</p>
{/if}

{if $status == "logout"}
   {include file="logout_form.html"}
{elseif $status== "none"}
   <p>Contact: John Rambo</p>
{else}
   {include file="login_form.html"}
{/if}

{include file="footer.html"}
Back to top
View user's profile Send private message
Ancient
Smarty Pro


Joined: 07 Jul 2007
Posts: 196
Location: Omaha, Nebraska, United States of America

PostPosted: Wed Feb 13, 2008 11:34 pm    Post subject: Reply with quote

Smarty has session data, along with get, request and post.

Code:
{if $smarty.session.logged_in}Shopping Cart{else}Login Required!!!{/if}


$smarty.session.what_ever_session_name_is
_________________
Smarty all the way.
Back to top
View user's profile Send private message Send e-mail MSN Messenger
kent.fallman
Smarty Rookie


Joined: 12 Feb 2008
Posts: 5

PostPosted: Thu Feb 14, 2008 5:26 am    Post subject: Reply with quote

Nice! Very Happy
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
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 vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP