[advanced search]
 

Go Back   NamePros.com > Discussion > Web Design & Development > Programming

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


Closed Thread
 
LinkBack Thread Tools
Old 08-16-2006, 09:54 PM   #1 (permalink)
Senior Member
 
Join Date: Jan 2006
Posts: 4,140
5,730.67 NP$ (Donate)

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

Ethan Allen Fund Cancer Survivorship Special Olympics Protect Our Planet Autism Save a Life AIDS/HIV AIDS/HIV Marrow Donor Program Cancer Survivorship Protect Our Planet Child Abuse Alzheimer's Cancer Breast Cancer Multiple Sclerosis Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009
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.

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 is offline  
Old 08-16-2006, 09:58 PM   #2 (permalink)
Senior Member
 
Camron's Avatar
 
Join Date: Jan 2006
Location: Portland, Oregon
Posts: 2,059
24.85 NP$ (Donate)

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!";
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.
__________________
|| VPSByte Virtual & Dedicated Solutions
|| True 24/7/365 support with a 1 hour guaranteed response time!
|| We offer budget, yet powerful dedicated servers and vps solutions.
|| All servers come w/ 10Mbps unmetered bandwidth & lite management standard.
Camron is offline  
Old 08-17-2006, 12:24 AM   #3 (permalink)
NamePros Member
 
Join Date: Aug 2006
Location: amsterdam
Posts: 93
494.50 NP$ (Donate)

Ms Grace will become famous soon enoughMs Grace will become famous soon enough


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
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, 04:56 AM   #4 (permalink)
NamePros Member
 
Join Date: May 2006
Posts: 160
81.00 NP$ (Donate)

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, 08:25 AM   #5 (permalink)
Senior Member
 
Join Date: Jan 2006
Posts: 4,140
5,730.67 NP$ (Donate)

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

Ethan Allen Fund Cancer Survivorship Special Olympics Protect Our Planet Autism Save a Life AIDS/HIV AIDS/HIV Marrow Donor Program Cancer Survivorship Protect Our Planet Child Abuse Alzheimer's Cancer Breast Cancer Multiple Sclerosis Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009
Quote:
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.

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 is offline  
Closed Thread


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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Site Sponsors
Advertise your business at NamePros

All times are GMT -7. The time now is 06:36 AM.


Powered by: vBulletin® Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0
Template-Modifications by TMS
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85