Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.

How is it done?

 
Post new topic   Reply to topic    Smarty Forum Index -> Smarty Development
View previous topic :: View next topic  
Author Message
Joedown
Smarty Rookie


Joined: 26 Jul 2004
Posts: 6

PostPosted: Wed Jul 28, 2004 5:29 pm    Post subject: How is it done? Reply with quote

I have a couple questions on accessing and displaying content. I have a sub directory that contains all the content files. How are they requested? Is this by the URL? Something like http://domain.com/index.php?=article1.html ? How would this be passed into the template file? I assume a variable? The second is where and how to read the title of the page from? I'm guessing the title should be in the article as <title>article title</title> and read from there? Looking at the demo it looks like the title is read from the index.tpl file but I don't see what the purpose of that is. Any examples of the above appreciated.
Back to top
View user's profile Send private message
Joedown
Smarty Rookie


Joined: 26 Jul 2004
Posts: 6

PostPosted: Thu Jul 29, 2004 7:48 pm    Post subject: Reply with quote

Ok, I have figured out my first question but I have not found any way to change the title tag. The only thing I can think to do is include the title in the article file and somehow read that. Every thing I have read sets the title in a conf file or in the php script as a variable which is fine if you have a website with one page or you want all your pages to have the same title. Any ideas on this one? I don't know much PHP so an example would be great. Smile
Back to top
View user's profile Send private message
garytheprogrammer
Smarty Rookie


Joined: 28 Jul 2004
Posts: 5
Location: Eugene, Oregon

PostPosted: Fri Jul 30, 2004 12:16 am    Post subject: title Reply with quote

Hi JoeDown,
Here is one way...
Assign the title in the php file like:
Code:
$smarty-&gt;assign('title'         ,       &quot;My Title&quot;);
$smarty-&gt;display('mypage.tpl');

then in mypage.tpl:
Code:
{include file=&quot;header.tpl&quot;}

and in my generic header:
Code:

&lt;html&gt;
&lt;head&gt;
&lt;title&gt;{$title}&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;


Opening a file in php and assigning it to a template var can really work well with any file... Just read the file into a string and assign it. (Parent templates pass on their vars to child templates when using the include syntax)


Last edited by garytheprogrammer on Wed May 05, 2010 10:47 pm; edited 1 time in total
Back to top
View user's profile Send private message
Joedown
Smarty Rookie


Joined: 26 Jul 2004
Posts: 6

PostPosted: Fri Jul 30, 2004 3:40 pm    Post subject: Reply with quote

Ok, that looks similiar to the other examples I have seen but I'm not understanding where the actual page title gets read from? Sad
Back to top
View user's profile Send private message
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Fri Jul 30, 2004 11:41 pm    Post subject: Reply with quote

The page title isn't read from--it is assigned, typically by the php script that is calling $smarty->display().
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Smarty Forum Index -> Smarty Development 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