Jump to content


Help Please: PHP includes


8 replies to this topic

#1 alexames

    Young Padawan

  • Members
  • Pip
  • 234 posts
  • Location:Uk
  • Interests:Webdesign / Graphics / Cars

Posted 25 May 2005 - 02:21 PM

Right here is the problem guys. I have created my own website. In total i have created 9 different pages.

On all of the pages i have many of the things the same, such as the header, the main navigation, recent news articles, site spotlight and the statistics box.

The only other box on the page is the main content box, which contains the different information on each page. The header doesnt seem to reload for each page but everything else on the page does. Also whenever i want to edit the site in site spotlight, i have to edit all 9 pages!

Is there a way i can just have site spotlight uploaded once and it to be able to run on each of my pages?

This in my theory should speed up page creation time alot and also be alot easier for my to edit with new content.

Im coding in PHP, and dont know what else to try. I think includes might be the key but i dont know how. I have tried to explain this problem as much as i can.

Link To My Site

AiMZEE DESiGNS v1

Thanks for any help you can give me.

alex

#2 maansson

    Young Padawan

  • Members
  • Pip
  • 132 posts
  • Gender:Male
  • Location:Lund, Sweden
  • Interests:Hmm, not much for Photoshop. Havn't taking time to learn it yet. Use Fireworks to the graphical area. More into coding and stuff. PHP, CSS, Java and of course HTML.

Posted 25 May 2005 - 04:56 PM

Make a index page and let all your 9 pages load from it, with a switch-case thingy. An example:
<?php
$_GET['page'];  
switch($page) 
{ 
case "home": 
include('main.php');
break;
case "news": 
include('news.php');
break; 
case "tutorials": 
include('tutorials.php');
break;
case "contact": 
include('contact.php');
break; 
case "sitemap": 
include('sitemap.php');
break; 
case "admin": 
include('admin.php');
break; 
default: 
include('main.php');
break;
} 
?>
Place this in your content box, and voila. By using different links you will get different pages. The links looks like this:
<a href="index.php?page=home">Home</a>
<a href="index.php?page=news">News</a>
<a href="index.php?page=tutorials">Tutorials</a>
and so on...
This is the most effective way of dealing with several pages without having to change every page.

Sincerely yours,
maansson

#3 alexames

    Young Padawan

  • Members
  • Pip
  • 234 posts
  • Location:Uk
  • Interests:Webdesign / Graphics / Cars

Posted 25 May 2005 - 05:25 PM

Thanks alot for replying mate. :)

I will try that out right away, seems simple enough to do, and will let you know if i can get it so work. :)

#4 squr3l

    Jedi In Training

  • Members
  • PipPip
  • 479 posts
  • Location:California
  • Interests:GFX, SFX, IT Specialist

Posted 25 May 2005 - 05:28 PM

and also, your about page is missing the about.php file :)

#5 alexames

    Young Padawan

  • Members
  • Pip
  • 234 posts
  • Location:Uk
  • Interests:Webdesign / Graphics / Cars

Posted 25 May 2005 - 05:36 PM

Nah it isnt missing, im still woking on it on my PC, i havnt uploaded it as of yet. :)

I just wrote about.php in myself so i knew that was the right page. Cheers for noticing tho.

Ive finished the index page now, moving onto the content box code now. :)

______________________________________

*UPDATE*
______________________________________

*sorry about double post*

Right im still having trouble with this :(

I think im doing the right thing im not sure. Ive found this aswell which i think is what im after.

http://www.pixel2lif...?showtopic=5234

and im also gonna follow this to give me a better idea on what i have to actually do. :)

alex

______________________________________

*UPDATE*
______________________________________

Wahoo, finally. I understand the idea of pageswitch in PHP.

Here is my latest.

// TEST // LATEST AiMZEE DESiGNS v1 // TEST //

Yeah i know i still need to sort the links out at the top, but i will sort that out tomorrow.

I will also sort out my CCS tomorrow,

and then try and figure out how to make my pages valid by w3.org standards.

Then mabey add an RSS feed on my news section. :)

Thanks for all your help mate !! :D

alex

______________________________________

*UPDATE*
______________________________________

Yey, finished!

//AiMZEE DESiNGS v1

And ive also done the CCS. :)

alex

#6 fiv3isaliv3

    Young Padawan

  • Members
  • Pip
  • 258 posts
  • Gender:Male

Posted 26 May 2005 - 04:33 PM

looks good. something doesn't seem right though with the way the page is loading.

#7 alexames

    Young Padawan

  • Members
  • Pip
  • 234 posts
  • Location:Uk
  • Interests:Webdesign / Graphics / Cars

Posted 26 May 2005 - 07:12 PM

Thanks mate. :hi: Yeah i know, my navigation seems to load quicker than the content and other boxes, and looks like its in the middle, then when the page loads up it seems ok. Dunno whats up, not a big problem tho.

This w3.org compliant is doing my head in now! :lol: Cant get it to work! lol

#8 JoeVincetti

    Young Padawan

  • Members
  • Pip
  • 82 posts

Posted 29 May 2005 - 11:27 PM

If you can't figure out how to use the page navigation, you could always use an iframe.
Though many people don't like using iframes, and you're probably much better off learning the php page navigation. Most decent sites are now using it because it makes it so much easier to edit your site.

#9 maansson

    Young Padawan

  • Members
  • Pip
  • 132 posts
  • Gender:Male
  • Location:Lund, Sweden
  • Interests:Hmm, not much for Photoshop. Havn't taking time to learn it yet. Use Fireworks to the graphical area. More into coding and stuff. PHP, CSS, Java and of course HTML.

Posted 30 May 2005 - 05:03 PM

JoeVincetti, on May 30 2005, 06:27 AM, said:

If you can't figure out how to use the page navigation, you could always use an iframe.
Though many people don't like using iframes, and you're probably much better off learning the php page navigation. Most decent sites are now using it because it makes it so much easier to edit your site.
The whole idea with pixel2life is to be developing, and iframe is not a part of developement. Iframes sucks, and that's it. Learn the right way or not a way at all. Even tables, which isn't the right way according to the web standards are much much better. You only need to get it right, and to think a little. I hate when proffessional sites uses iframes.

Good looking site btw, alexames. Glad to see my long time writing example came in use...

Sincerely yours,
maansson





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users