|
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 |
Joedown Smarty Rookie
Joined: 26 Jul 2004 Posts: 6
|
Posted: Wed Jul 28, 2004 5:29 pm Post subject: How is it done? |
|
|
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 |
|
Joedown Smarty Rookie
Joined: 26 Jul 2004 Posts: 6
|
Posted: Thu Jul 29, 2004 7:48 pm Post subject: |
|
|
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. |
|
Back to top |
|
garytheprogrammer Smarty Rookie
Joined: 28 Jul 2004 Posts: 5 Location: Eugene, Oregon
|
Posted: Fri Jul 30, 2004 12:16 am Post subject: title |
|
|
Hi JoeDown,
Here is one way...
Assign the title in the php file like:
Code: | $smarty->assign('title' , "My Title");
$smarty->display('mypage.tpl'); |
then in mypage.tpl:
Code: | {include file="header.tpl"} |
and in my generic header:
Code: |
<html>
<head>
<title>{$title}</title>
</head>
<body> |
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 |
|
Joedown Smarty Rookie
Joined: 26 Jul 2004 Posts: 6
|
Posted: Fri Jul 30, 2004 3:40 pm Post subject: |
|
|
Ok, that looks similiar to the other examples I have seen but I'm not understanding where the actual page title gets read from? |
|
Back to top |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Fri Jul 30, 2004 11:41 pm Post subject: |
|
|
The page title isn't read from--it is assigned, typically by the php script that is calling $smarty->display(). |
|
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
|