|
|
Server side includes + php!
|
|
|
|
Mac Elite
Join Date: May 2001
Status:
Offline
|
|
G'day!
I'm working on a site at the moment for a school, see here:
http://www.assumption.com.au/index.shtml
At the top of each page is a javascript menu which provides the navigation for the site. In order to cut down on file size, and keep the site more manageable, I used server side includes to include the menu on each page. That way when I want to update the menu, I can change just one file (well, 3 actually, but still).
All is good! This works well, especially considering it is my first go at using javascipt menus, and my first shot at using server side includes!
But!!! Now for the news section, I want to make the pages php. On my 'normal' html pages, when I want to include php, I just change the file extension to .php and then put in any php I want. The problem is, that in order for my server-side includes to work, the files need a file extension of .shtml. If I change this to .php, the server-side includes don't work, and I don't have any navigation.
Question:
How can I change the file extension to .php , yet make the server realise that these documents have server side includes?
Thanks a lot for any help you might have.
|
|
|
|
|
|
|
|
|
Grizzled Veteran
Join Date: Jun 2001
Location: Melbourne, Australia
Status:
Offline
|
|
If the include was written like this in your .shtml files:-
[php]
<!--#include virtual="/your/file/here.inc" -->
[/php]
then you simply change it to:-
[php]
<?php include($_SERVER['DOCUMENT_ROOT']."/your/file/here.inc") ?>
[/php]
within each php file. I'm assuming you're using a 'NIX based server - if you're running IIS then you need to replace $_SERVER['DOCUMENT_ROOT'] with the actual filepath of your virtual server (e.g. "C inetpub\wwwroot\")
|
Computer thez nohhh...
|
|
|
|
|
|
|
|
Mac Elite
Join Date: May 2001
Status:
Offline
|
|
Simon: You're good! Works a bloody charm! Much easier than expected also!
Question: (for anyone, yourself included)
Is there a good reason to use one of these options over the other one? Would I be better off changing the <--include virtual> includes to these php ones?
What do you prefer to use and why?
|
|
|
|
|
|
|
|
|
Grizzled Veteran
Join Date: Jun 2001
Location: Melbourne, Australia
Status:
Offline
|
|
Originally posted by thePurpleGiant:
Simon: You're good! Works a bloody charm! Much easier than expected also!
Question: (for anyone, yourself included)
Is there a good reason to use one of these options over the other one? Would I be better off changing the <--include virtual> includes to these php ones?
What do you prefer to use and why?
I don't bother with SSI anymore, as PHP is pretty quick these days and offers much more convenience and flexibility.
After a couple of years of trial and error, I've settled into a pattern of creating a few 'control' pages in PHP that take care of the logic of a website, then handle all the formatting and display using Smarty templates and its caching ability, so you get (very nearly) the speed of static pages but with much better control over your content.
And if you're going to program in PHP, I'd highly recommend using the PEAR classes for development - nearly anything that you need to do has already been thought of and turned into a class (creating dynamic forms, sending HTML emails, uploading files, Generic Database access, etc...)
My two cents!
(P.S. Hope this weather isn't melting you like it us is in this house!)
|
Computer thez nohhh...
|
|
|
|
|
|
|
|
Occasionally Useful
Join Date: Jun 2001
Location: Liverpool, UK
Status:
Offline
|
|
posting in legendary Australian Help thread
|
"Have sharp knives. Be creative. Cook to music" ~ maxelson
|
|
|
|
|
|
|
|
Mac Elite
Join Date: May 2001
Status:
Offline
|
|
Originally posted by Simon Mundy:
I don't bother with SSI anymore, as PHP is pretty quick these days and offers much more convenience and flexibility.
After a couple of years of trial and error, I've settled into a pattern of creating a few 'control' pages in PHP that take care of the logic of a website, then handle all the formatting and display using Smarty templates and its caching ability, so you get (very nearly) the speed of static pages but with much better control over your content.
And if you're going to program in PHP, I'd highly recommend using the PEAR classes for development - nearly anything that you need to do has already been thought of and turned into a class (creating dynamic forms, sending HTML emails, uploading files, Generic Database access, etc...)
Pear hey. That sounds handy (and tasty!)- me being the non-programmer that I am tends to stick to using the same thing (php). But this looks good. I will give it a shot (look out for future threads titled "Using Pear, Help!")
(P.S. Hope this weather isn't melting you like it us is in this house!)
Sure as heck was. Had a client in Geelong so I went to see them also. Car air conditioning is very nice. As is the beach on a hot day.
Originally posted by philzilla:
posting in legendary Australian Help thread
Thanks for the advice phil!
|
|
|
|
|
|
|
|
|
Mac Elite
Join Date: May 2001
Status:
Offline
|
|
...hang on a second. Does this mean that PEAR stands for:
Personal Home Page Hypertext Pre-Processor Extension and Application Repository??
Catchy.
|
|
|
|
|
|
|
|
|
Clinically Insane
Join Date: Oct 2000
Location: Los Angeles
Status:
Offline
|
|
Simon, your conversation with TPG was very helpful to me as well - thank you both.
|
"The natural progress of things is for liberty to yield and government to gain ground." TJ
|
|
|
|
|
|
|
|
Occasionally Useful
Join Date: Jun 2001
Location: Liverpool, UK
Status:
Offline
|
|
Originally posted by thePurpleGiant:
Thanks for the advice phil!
good job i was around to help
|
"Have sharp knives. Be creative. Cook to music" ~ maxelson
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Forum Rules
|
|
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
|
|
|
|
|
|