Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Server side includes + php!

Server side includes + php!
Thread Tools
thePurpleGiant
Mac Elite
Join Date: May 2001
Status: Offline
Reply With Quote
Feb 14, 2004, 09:26 PM
 
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.
     
Simon Mundy
Grizzled Veteran
Join Date: Jun 2001
Location: Melbourne, Australia
Status: Offline
Reply With Quote
Feb 14, 2004, 10:08 PM
 
Originally posted by thePurpleGiant:
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...
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. "Cinetpub\wwwroot\")
Computer thez nohhh...
     
thePurpleGiant  (op)
Mac Elite
Join Date: May 2001
Status: Offline
Reply With Quote
Feb 14, 2004, 10:24 PM
 
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?
     
Simon Mundy
Grizzled Veteran
Join Date: Jun 2001
Location: Melbourne, Australia
Status: Offline
Reply With Quote
Feb 15, 2004, 04:54 AM
 
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...
     
philzilla
Occasionally Useful
Join Date: Jun 2001
Location: Liverpool, UK
Status: Offline
Reply With Quote
Feb 15, 2004, 08:15 AM
 
posting in legendary Australian Help thread
"Have sharp knives. Be creative. Cook to music" ~ maxelson
     
thePurpleGiant  (op)
Mac Elite
Join Date: May 2001
Status: Offline
Reply With Quote
Feb 16, 2004, 02:11 AM
 
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!
     
thePurpleGiant  (op)
Mac Elite
Join Date: May 2001
Status: Offline
Reply With Quote
Feb 16, 2004, 02:17 AM
 
...hang on a second. Does this mean that PEAR stands for:

Personal Home Page Hypertext Pre-Processor Extension and Application Repository??



Catchy.
     
Big Mac
Clinically Insane
Join Date: Oct 2000
Location: Los Angeles
Status: Offline
Reply With Quote
Feb 16, 2004, 07:51 AM
 
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
     
philzilla
Occasionally Useful
Join Date: Jun 2001
Location: Liverpool, UK
Status: Offline
Reply With Quote
Feb 16, 2004, 11:36 AM
 
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 Links
Forum 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
Top
Privacy Policy
All times are GMT -4. The time now is 10:57 PM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,