Fetching files/pages from one 'template' page

This is a discussion on "Fetching files/pages from one 'template' page" within the PHP Forum section. This forum, and the thread "Fetching files/pages from one 'template' page are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > PHP Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Feb 24th, 2006, 19:59
Junior Member
Join Date: Feb 2006
Age: 25
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Fetching files/pages from one 'template' page

Hi guys,
At the mo I am using php function to fetch different data stored all in one page so that I only have to have the code for my header and navigation once and then I can display the different pages all from this page - if this makes sense.
I have since been told that I should be storing the other pages content in different files and fetching them from their... cos my page/file will be too big otherwise...
Does any1 have any idea how to do this please?
I would really appreciate any help/examples.
This is the way I am doing it currently
<?php
function getCSS($x) {
if ($x == $_GET["Section"]) {
echo "activeButton";
} else {
echo "button";
}
}
?>
<td align="middle"><a class="<?php getCSS("")?>"href="index.php">Home</a></td>
<td align="middle" width="1"><span class="style22">&nbsp;|&nbsp; </span></td>
<td align="middle"><a class="<?php getCSS("Registration")?>" href="index.php?Section=Registration">Free Registration</a></td>

<?php
switch ($_GET["Section"]) {
case "Registration":
Thanks very much
Brain.
Reply With Quote

  #2 (permalink)  
Old Feb 25th, 2006, 13:03
Up'n'Coming Member
Join Date: Feb 2006
Location: London
Age: 25
Posts: 98
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Fetching files/pages from one 'template' page

You can either use require_once() or include_once()...

If you use require_once(), the web page will not run at all if it can't find the required file.

If you use include_once(), the web page will continue to load if it can't find one of the files

Here's an example:

<?php require_once('includes/header.php');?>

<h1> I am content </h1>

<?php require_once('includes/footer.php');?>

Without crapping on too much, I use require_once in pretty much every situation for a few reasons...

Hope this helped!
Jim.
Reply With Quote
  #3 (permalink)  
Old Feb 25th, 2006, 16:23
Junior Member
Join Date: Feb 2006
Age: 25
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Fetching files/pages from one 'template' page

That's very helpful and informative...

I will try this method.


Thanks very much!!!

Brain
Reply With Quote
Reply

Tags
fetching, filespages, template, page

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Problems with Organising Website Files - Folders Stop My Pages from Displaying thebagman Website Planning 10 Sep 4th, 2007 22:12
Template? pages Paul in London Web Page Design 1 Apr 24th, 2007 18:55
Finding un-linked or un-used pages and files??? rjrichar40 Starting Out 3 Apr 19th, 2007 21:53
front page 2003 and psd files faygirl Scripts and Online Services 4 Nov 20th, 2006 14:31
Css pages and page breaks bjorkli Web Page Design 0 Aug 12th, 2005 13:29


All times are GMT. The time now is 05:44.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

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