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

Login block inside a page

 
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
maurodx
Smarty Rookie


Joined: 28 Apr 2005
Posts: 6

PostPosted: Tue May 17, 2005 7:54 am    Post subject: Login block inside a page Reply with quote

Hi guys,
i have a newbie problem with smarty.

I have created some page with a static header.tpl, a static footer.tpl and a dynamic content.

Now, in the header i want to insert a login block, so (in my erroneous thinking...) i create a login.php that ends with $tpl->display('login.tpl')

no way to make it run!

What techniques I have to use? thanks a lot
Back to top
View user's profile Send private message
joey
Smarty Regular


Joined: 29 Oct 2003
Posts: 57

PostPosted: Tue May 17, 2005 10:00 am    Post subject: Re: Login block inside a page Reply with quote

maurodx wrote:
Hi guys,
i have a newbie problem with smarty.

I have created some page with a static header.tpl, a static footer.tpl and a dynamic content.

Now, in the header i want to insert a login block, so (in my erroneous thinking...) i create a login.php that ends with $tpl->display('login.tpl')

no way to make it run!

What techniques I have to use? thanks a lot


1. You should create a login.php to show your login.tpl. If you done,show us your codes.

2. In your main template. use {include_php file="xxx.php"} to include your login block. when u visit your main page,you will see login block.
_________________
Joey
Senior Developer & Designer
-------------------------------------------
http://www.propagator.net
[SourceForge Project] Formcat with Smarty!
http://www.propagator.net/formcat/
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
iamcam
Smarty n00b


Joined: 07 Apr 2005
Posts: 3
Location: San Diego

PostPosted: Tue May 17, 2005 9:40 pm    Post subject: Reply with quote

That's a good idea, using include_php, however that smarty function is pretty much deprecated. (http://smarty.php.net/manual/en/language.function.include.php.php).


Instead, writing a custom function is suggested:
http://smarty.php.net/manual/en/tips.componentized.templates.php
_________________
~Cameron
Back to top
View user's profile Send private message
mitchenall
Smarty Pro


Joined: 27 Feb 2004
Posts: 107
Location: London, UK

PostPosted: Sun May 22, 2005 9:33 am    Post subject: Re: Login block inside a page Reply with quote

maurodx wrote:
What techniques I have to use? thanks a lot


We use our 'widget' plugins for this. These are based on a simple widget abstract class which defines two methods: display() and formHandler(). The display() is called from the plug-in when a widget is included in a template, e.g.

{widget name=widgetUserLogin template=login_form.html}

Each widget is a subclass of the widget class and there's a factory instantiate them from the plug-in and in the page_start scripts.

The login form template is output by the display() method, and display either a login form or the user's name, depending on whether they're logged in or not.

The formHandler() method simply checks form parameters passed and logs the user in or out as appropriate. Because it uses a singleton instance of the user object, it's easy for the form to check for the previous log-in error and display it.

Every page on our site will call an initialisation script 'page_start.php' which does all the config setups needed in every page. The page_start.php script also checks whether any widgetFormHandler parameters were passed in the request, and if there were, it uses the widgetFactory to create a widget instance, then calls it's form-handler as appropriate.

We don't always write formHandlers for widgets, but for things like log-in blocks, shopping carts, polls, etc., they're a very effective solution, because they can be called from any page on a site without additional coding. Just drop them in to the template and define which template they use.

HTH,

Mark
_________________
Mark Mitchenall
Back to top
View user's profile Send private message Visit poster's website
joeld
Smarty Rookie


Joined: 03 Mar 2005
Posts: 14

PostPosted: Mon May 23, 2005 9:10 pm    Post subject: Reply with quote

Mark, can you post a example about that you explained.
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