Forum Moderators: coopster
I'd like to `include` page elements within my documents. They would be the standard header, navigation and footer elements.
But for the header, that would require my `title` and `meta` tags be set-up as variables for each new page.
So where exactly do I put the information to fill those variables. On the .html page or the includes page?
Is this the correct assumption? What are some other ways of going about this?
Thanks for any help!
At the top of each page I call my "header"...
#####################
<?require ("/full/path/to/top.html");?>
#####################
"top.html" looks something like this:
#####################
// call my "config" file
<?require_once("/full/path/to/template_config.html");?>
<HTML><HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<?echo("$Title\n");?>
<meta name="keywords" content="<?echo("$Keywords");?>">
<meta name="description" content="<?echo("$Description");?>">
#####################
"template_config.html" looks like this:
#####################
<?
if($PATH_TRANSLATED == "/full/path/to/page1.html"){
$Title="<TITLE>Welcome to Page 1</TITLE>";
$Description="This is page 1. It is a good page.";
$Keywords="keyword1,keyword2,keywortd3";
$header_text="<P ALIGN=\"CENTER\"><font face=\"Arial, Helvetica, sans-serif\" size=\"3\" color=\"#6363ef\"><B>Welcome to Page 1!</B></font></P>";
$header_jpg="http://www.yourdomain.com/images/page1_header.jpg";
}
else if($PATH_TRANSLATED == "/full/path/to/page2.html"){
$Title="<TITLE>Welcome to Page 2</TITLE>";
$Description="This is page 2. It is a good page.";
$Keywords="keyword1,keyword2,keywortd3";
$header_text="<P ALIGN=\"CENTER\"><font face=\"Arial, Helvetica, sans-serif\" size=\"3\" color=\"#6363ef\"><B>Welcome to Page 2!</B></font></P>";
$header_jpg="http://www.yourdomain.com/images/page2_header.jpg";
}
// etc., etc., etc....
?>
#####################
Hope that helps.
Friday
[edited by: Friday at 4:23 pm (utc) on Sep. 11, 2003]
<?include "/full/path/tol/navbar.html";?>
##############################
<?
$links_arr = array("Home" => "http://www.YourDomain.com/",
"Store Tour" => "http://www.YourDomain.com/departments.php4",
"Shop" => "http://www.YourDomain.com/cart/",
"Classes/Events" => "http://www.YourDomain.com/classes.php4",
"About Us" => "http://www.YourDomain.com/about_us.php4",
"Find Us" => "http://www.YourDomain.com/find_us.php4",
"Forums" => "http://www.YourDomain.com/sewing_circle.php4",
"Tips" => "http://www.YourDomain.com/sewing_tips.php4",
"Services" => "http://www.YourDomain.com/special_services.php4");
$separator = " <FONT SIZE=\"1\" FACE=\"Times New Roman, Times, Serif\">¦</FONT> ";
for (reset($links_arr); $name = key($links_arr); next($links_arr)){
$hyper = 1;
if(strstr($PATH_TRANSLATED,$links_arr[$name])) {
$hyper = 0;
}
if ($hyper) {
print "<FONT FACE=\"Arial, Helvetica, sans-serif\" SIZE=\"1\">
<A HREF=\"" . $links_arr[$name]."\">$name";
}
#print $name;
if ($hyper){
print "</A></FONT>";
}
if ($hyper == 0){
print "<FONT FACE=\"Arial, Helvetica, sans-serif\" SIZE=\"1\" color=\"#006b6b\"><B>$name</B></FONT>";
}
if(next($links_arr)){
print $separator;
prev($links_arr);
}
}
?>
header.php:
<!-- Start -->
<html>
<head>
<title><?=$html_title?></title>
</head>
<body>
<!-- End -->
footer.php:
<!-- Start -->
</body>
</html>
<!-- End -->
mynewpage.php
<!-- Start -->
<?
$html_title='this is the title of my page';
include 'header.php';
?>
This is my content
<?include 'footer.php'?>
Obviously my actual files are a little more complicated but you get the idea. That way you set the HTML element variables then include the header. So each file contains it's content and title,meta desc,keywords or whatever.
daisho.
I was wondering why you used the config file