Hello,
I'm having a hard time getting the title of each page to appear in the Browser top bar.
I have followed several tutorial that instruct on how to achieve this result but none work. i know it's because of the somehow odd structure each of my website's pages have. Unfortunately I cannot change it (the site has so many pages it will be madness to change all of them!).
This is the best tutorial I found:
http://www.alistapart.com/articles/keepingcurrent
<?php $thisPage="About Us"; ?>
<head><html>
<title>Company Name<?php if ($thisPage!="")
echo " | $thisPage"; ?></title>
It advises me to set the page title at the top of each page, before the header is called. I cannot do this because each of my pages is constructed this way, using Smarty templates.
example.php
is created by smarty with the following code:
$main_content = $smarty->fetch('example.tpl');
$smarty->assign("MAIN_CONTENT",$main_content);
$smarty->display('main.tpl');
So the first first we look at is the main.tpl template.
main.tpl (simplified for this example)
{php}
include('header.htm');
{/php}
<div id="canvas">
{php}
include('navigation-user.php');
{/php}
<div id="main">
{$MAIN_CONTENT}
</div>
{php}
include('footer.htm');
{/php}
</div>
</body>
</html>
So the main.tpl page includes the header:
header.htm
!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Title for each page is what I want! </title>
<link href="css/style.css" rel="stylesheet" type="text/css" />
</head><body>
The the maint.tpl template creates the site frame and inserts the content of the example.tpl page (as instructed by Smarty in the example.php page).
This is the structure of each page. For this reason I don't seem the be able to give a unique $thisPage value to each page, seeing as the header is the same for all pages.
For the same reason, I cannot use the instructions published on the smarty website:
http://smarty.php.net/crashcourse.php
<html>
<head>
<title>{$title|default:"no title"}</title>
</head>
<body>
{include file="header.tpl" title="User Info"}
User Information:<p>
Name: {$name|capitalize}<br>
Address: {$address|escape}<br>
{include file="footer.tpl"}
is there a workaround? Some smarter way of achieving the same result?
I'm only a newbie, on my first post here. If you are so kind to help, please do soo in simple words!
Much appreciated, really!
Cheers
manula