|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
maurodx Smarty Rookie
Joined: 28 Apr 2005 Posts: 6
|
Posted: Tue May 17, 2005 7:54 am Post subject: Login block inside a page |
|
|
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 |
|
joey Smarty Regular
Joined: 29 Oct 2003 Posts: 57
|
Posted: Tue May 17, 2005 10:00 am Post subject: Re: Login block inside a page |
|
|
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 |
|
iamcam Smarty n00b
Joined: 07 Apr 2005 Posts: 3 Location: San Diego
|
|
Back to top |
|
mitchenall Smarty Pro
Joined: 27 Feb 2004 Posts: 107 Location: London, UK
|
Posted: Sun May 22, 2005 9:33 am Post subject: Re: Login block inside a page |
|
|
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 |
|
joeld Smarty Rookie
Joined: 03 Mar 2005 Posts: 14
|
Posted: Mon May 23, 2005 9:10 pm Post subject: |
|
|
Mark, can you post a example about that you explained. |
|
Back to top |
|
|
|
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
|