Forum Moderators: coopster
I need to add tailored content to every page based on the category which that page is in. i.e. a dynamic page title, meta description, meta keywords, category links would all be customised based on the category.
The objective is to make the list of variables (the tailored content) maintainable from one central source. This will simplify maintenance, and mass updates across the site.
What commands/code do I need so that it checks to see for e.g. that the page is in the 'Teams' category, and then pulls all the variable information about Teams? and then when a page on 'Players' is selected, it pulls all the variable information about Players etc.
Is this possible? I presume it must be...I'm new to php, I really appreciate any advice or direction on how I might achieve this
THANK YOU
It might seem overwhelming at first, but believe me, the result will be better and you'll most likely spend less time setting up a CMS than writing one yourself. There are a bunch of freely available CMS'es in PHP that shouldn't be too hard to get hosted. I'm still unsure of the URL posting rules here so I'll just name them, you'll find them ;)
Drupal (never used myself but people like it)
eZ (norwegian CMS, very complex and heavy, but also VERY configurable. A little steep learning curve but a great tool)
And one that's really simple: Wordpress. Not really a CMS, but rather a blog software. It's easy to get up and running and easy to configure. It might just be enough for your needs. ('Blogify' your problem: create one category for each type of page - player, stadium and so on. Make the archive for players be the player section and so on. Add custom fields to 'posts' in the player 'archive' that qualifies a player.)
thanks for the post. Implementing a content mgmt solution is not an option at this stage, but i'll certainly look at it later, I appreciate the comments on tools.
This is just a very basic starter for you but somthing you can work with.
*****index.php****
<?php
// Include Your Header File
include("header.php");
// Set your variable $page
$page = $_GET[page];
// Condition, If no page is selected then it returns the main.php (or whatever you want your main intro page to be)
if($page=="") {
include("pages/main.php");
}
// If a Page is selected then do the following.
else
{
include("pages/".$page.".php");
}
//Include Your Footer File
include("footer.php");
die;
?>
Then in your header.php file for the title of the page
****header.php****
<?php
// define your $head Variable
$head = $_GET[page];
?>
<head>
<!-- If no page is selected the title will echo 'Football :: Main Page'. Otherwise it will echo 'Football :: Season 2005/6'
<title>Football :: <? if($head=="") { echo "Main Page" }
else { echo $head; }
?></title>
</head>
Thats to change the Page Title's. You can work on the same principle for Page Descriptions, but I will leave that for you ;-)
Dwighty
I am also working on a Football Site (Soccer) so maybe we could work together. Hopefully over the weekend I will be writing a script which will do what i believe you want. We can work through that if you want.
Are you working with a database or not? If not the solution would be to define variables e.g.
$Coachs = "An Overview on all of the Coachs in the Game";
Or something like that...
More to follow.
In the mean time, if anyone can suggest different ways to approach this that would be good.
Dwighty
$category=players //for pages about football players
and then have the following code in all pages
if($category=="players") {
include("players_links.php");
}
else
if($category=="teams") {
include("teams_links.php");
}
else
if($category=="coaches") {
include("coaches_links.php");
}
else
{
include("no_links.php");
}
Syntax may need some fixup but in principle would that work? Thanks