NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming
Reload this Page Simple PHP Question

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.

Advanced Search


Closed Thread
 
LinkBack Thread Tools
Old 08-16-2006, 10:54 PM THREAD STARTER               #1 (permalink)
Senior Member
Join Date: Jan 2006
Posts: 4,204
Steve has a reputation beyond reputeSteve has a reputation beyond reputeSteve has a reputation beyond reputeSteve has a reputation beyond reputeSteve has a reputation beyond reputeSteve has a reputation beyond reputeSteve has a reputation beyond reputeSteve has a reputation beyond reputeSteve has a reputation beyond reputeSteve has a reputation beyond reputeSteve has a reputation beyond repute
 



Simple PHP Question


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.
????: NamePros.com http://www.namepros.com/programming/228500-simple-php-question.html

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
__________________
Steve
NamePros Staff Emeritus
Steve is offline  
Old 08-16-2006, 10:58 PM   #2 (permalink)
Senior Member
 
Camron's Avatar
Join Date: Jan 2006
Location: Portland, Oregon
Posts: 2,102
Camron has much to be proud ofCamron has much to be proud ofCamron has much to be proud ofCamron has much to be proud ofCamron has much to be proud ofCamron has much to be proud ofCamron has much to be proud ofCamron has much to be proud ofCamron has much to be proud of
 



VA Tech Memorial 9/11/01 :: Never Forget Cancer Survivorship Child Abuse
Quote:
<?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!";
????: NamePros.com http://www.namepros.com/showthread.php?t=228500
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.
__________________
HostingFuze.com Premium Master Reseller Services | 99.9% Uptime Guaranteed SLA | Starting at $4.95/mo
Basic Reseller Hosting @ HostFz.com - Services starting as low as $1.95/mo!
Camron is offline  
Old 08-17-2006, 01:24 AM   #3 (permalink)
NamePros Member
Join Date: Aug 2006
Location: amsterdam
Posts: 93
Ms Grace is a jewel in the roughMs Grace is a jewel in the roughMs Grace is a jewel in the rough
 



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 Code:
<?php
switch ($_GET[page]) {
//homepage
default:
include(
"main.php");
break;

//news or whatever
????: NamePros.com http://www.namepros.com/showthread.php?t=228500
case 'news':
include(
"news.php");
break;
}
?>
The separate content files would look something like this:

main.php:
HTML Code:
Welcome to xxx.com. Please take the time to browse around !
main.php:
HTML Code:
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...
__________________
Directory Bids | ArcadeCharts.com | Play Arcade Games
CasinoPremiums.com | DrmRemover.com | InsuranceBasic.com | Pedicure.cc | 32-bit.com | BearDolls.com
Ms Grace is offline  
Old 08-17-2006, 05:56 AM   #4 (permalink)
NamePros Member
Join Date: May 2006
Posts: 160
TwistMyArm is on a distinguished road
 



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...
TwistMyArm is offline  
Old 08-17-2006, 09:25 AM THREAD STARTER               #5 (permalink)
Senior Member
Join Date: Jan 2006
Posts: 4,204
Steve has a reputation beyond reputeSteve has a reputation beyond reputeSteve has a reputation beyond reputeSteve has a reputation beyond reputeSteve has a reputation beyond reputeSteve has a reputation beyond reputeSteve has a reputation beyond reputeSteve has a reputation beyond reputeSteve has a reputation beyond reputeSteve has a reputation beyond reputeSteve has a reputation beyond repute
 



Originally Posted by TwistMyArm
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.
????: NamePros.com http://www.namepros.com/showthread.php?t=228500

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!
__________________
Steve
NamePros Staff Emeritus
Steve is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


Liquid Web Smart Servers  
All times are GMT -7. The time now is 07:07 PM.

Managed Web Hosting by Liquid Web
Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger