Forum Moderators: coopster
There's a few of ways you can do this, use a switch statement to use a set of tags for a specific page, have a database table containing the data, or you could just use a flat text file with the page names relating to the keyword etc.
I would stick with one of those methods, although you could code a function to scan each page as it loads and pull out interesting words from the content, leaving out non-specific words.
--
Crispy
ie:
I suposso you have somethig like (I'll use * instead of '<' '>' html delimiters to avoid messing the forum, just in case)
*title*Current title here*/title*
then you have to use something like (usign *% for php delimiters)
*% // php code starts here
if ($condition == 1) echo ("*title*Title one here*/title*");
elseif ($condition == 2) ("*title*Title two here*/title*");
.
.
// ans so on
%* // php code terminates here
and you can do it with every html tag you want.
Hope this help.
For example I run a shop and base the meta tags on product pages, specifically that product and it's description, so each product page has a different title, description and set of keywords that relate to it, therefore each should be indexed as individual pages.
--
Crispy
under body, i have:
switch($_GET['category']){
case 'category1':
//content for category 1
break;
case 'category2':
//content for category 2
break;
}
each category has different content, so i want to change the title tag to show the category's title, not the default one. Hope this make sense :)
function genMeta ($section) {
switch ($section) {
case 'catalogue':
// Code for catalogue page
break;
case 'about':
// Code for about page
break;
default:
break;
}
}
Then in my html I have the following:
<?php
// Code to grab the section var from the url here...
?>
<html>
<head>
<?php genMeta($section);?>
</head>
<body>
...whatever...
</body>
</html>
You can see how clean it makes your html too, so there's not lots of if else ifs about the place.
--
Crispy