Dynadot โ€” .com Transfer

Simple PHP Question

SpaceshipSpaceship
Watch
Hello,

I've had a web page going for a little while now using very basic PHP (includes). However, the way I'm doing it seems rather inefficient compared to other sites I've worked on (but not built) before.

http://scca-racing.com/

As you can see, every page with content on it (with the exception of the forum) uses the same basic page template -- the header, left side, background, content area, and the copyright area. Right now, I have a basic "framework" for each page, that is simply the blank squares of each section. Where the main content area is, I have it including a page from my includes/ folder, which is just the content displayed there.

For example, on the Cup Series standings page: In my root directory I have cupstandings.php, which is the "framework" of the page that has an include to includes/header.php, includes/left.php, includes/copyright.php and includes/cupstandings.php, which is the content of the page.

Is there a way to simplify this process of creating a new framework page and only changing what one div layer includes for each page? I'd really like to just have one framework page that displays whatever content I ask it to. For example, if I have a file "octopus.php" in my includes/ folder, I'd like to be able to type in a URL that is actually the "framework" of that page with "octopus.php" as the content, sort of like "http://scca-racing.com/index.php?page=octopus.php" or something of that nature.

I don't really know what I'm talking about, but hopefully someone with more PHP knowledge than I have knows what to do. I've seen it done before, I just can't do it. Any help or advice is greatly appreciated! :)

Thanks,
Steve
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
<?php

$header = "";
$footer = "";
$side = "";

switch ($HTTP_GET_VARS[page]) {

//homepage
default:
echo "$header";
echo "$side";
echo "Welcome to my site, homepage!";
echo "$footer";
break;

//secondary page
case 'octopus':
echo "$header";
echo "$side";
echo "Welcome to octopus page!";
echo "$footer";
break;
}
?>

Is that what your looking for?

Just edit $var in the top ($header = "HEADER HTML GOES HERE";), and the same for the rest. When you go to index.php?page=octopus it will show the header/side bar/footer and will say Welcome To octupus page!

Let me know if that's what you were looking for.

Thanks.
 
1
•••
would what you could do is is make one page (index.php) that holds the standard non-changing stuff like: header, footer ect.
and make separate little files for the content (variable) part.
then you could include the file needed, depending on the page that was called like this:

in index.php you then place this where you want the content to show up:

PHP:
<?php
switch ($_GET[page]) {
//homepage
default:
include("main.php");
break;

//news or whatever
case 'news':
include("news.php");
break;
}
?>

The separate content files would look something like this:

main.php:
HTML:
Welcome to xxx.com. Please take the time to browse around !

main.php:
HTML:
This is the news section of the site !

that way you can call pages like this index.php?page=news
kind of like the way StackedTech allready explained.

This may not be the most efficient way to do things but it is a way

Hope I explained that clear enough...
 
1
•••
I appreciate that you've put a lot of work into your site, but it's the perfect candidate for a CMS: why not use one? I believe it would help in the long run...
 
0
•••
TwistMyArm said:
I appreciate that you've put a lot of work into your site, but it's the perfect candidate for a CMS: why not use one? I believe it would help in the long run...
We had used a CMS in the past but decided it caused too many errors and site issues to be worthwhile. It made things very easy at first until things started to break.

StackedTech and Ms Grace, I was able to get things exactly the way I want them, it's as efficient as I need it to be, and it's very simple. Thanks a lot, rep coming your way! :)
 
0
•••
Dynadot โ€” .com TransferDynadot โ€” .com Transfer
Appraise.net
Escrow.com
Spaceship
Rexus Domain
CryptoExchange.com
Domain Recover
CatchDoms
DomDB
NameFit
  • The sidebar remains visible by scrolling at a speed relative to the pageโ€™s height.
Back