Hi there! I'm new and a newbie when it comes to php - (I can hear the groans from here!)
My question revoles around enabling loading of php pages dynamically of the:
type.
I have seen posts on here where you can dynamically load the title tags (and so on) dependent on the page loaded (like the pretend link above) such as:
functions.php
<?php
function checkPage($arg) {
switch ($arg) {
case "home":
$title = "My home page";
break;
case "downloads":
$title = "My downloads";
case "contact":
$title = "Contact me";
break;
}
return $title;
}
with:
<?php include("functions.php");
$title = checkPage($_GET['page']);
?>
<doctype etc>
<head>
<title><?php echo $title;?></title>
</head>
Which results in the page having a title of "Contact me".
So, all good so far I guess.
I would like to take this a step further and load page content dependent on the ?page= part.
Therefore if the page loaded (either directly or by clicking a link in the html) was mysite.com/index.php?page=members then index would, as well as loading the header and footer dynamic title etc would also load content from members.php (for instance).
Is this a sensible approach and how could it be done?
Point to remember:
There will be a LOT of pages on the site but each would have the same (or similar) header/sidebar/footer. To that end I would do something like the below index.php but I am wondering about the above solution and how to implement it?
<html>
doctype etc
<head>
dynamic head content such as title/keywords and so on
static content such as css and js
</head>
<body>
<?php include "header.php"; ?>
<?php include "sidebar.php"; ?>
the content based on what page has been clicked (i.e. ?page=members)
<?php include "footer.php"; ?>
</body>
</html>
Hope you can help :-)