0

I have a site with pages with shtml extension, primarily done to have menu navbar display corrctly with SSI. I now am adding a page with php, and to have this page work properly I have given it a php extension, which causes the menu to no longer display. I also frankly find the shtml extension to be an odd one for most who use my site. I would like to change to php extension for all pages if possible, but how do I reformat my SSI to display properly if I no longer use the shtml extension?

The current code of interest is <!--#include virtual="/Navbar.shtml" -->

dmwesq
  • 131
  • 1
  • 4
  • 13

3 Answers3

0
<!--#include virtual="/Navbar.shtml" -->

to

<?php require '/Navbar.php' ?>
Alin Purcaru
  • 43,655
  • 12
  • 77
  • 90
  • To be sure I am doing as suggested, I renamed my two includes (Navbar and footer) from shtml to php. I then went to my template, and made the replacement above from the include virtual ... to the php require ... - I then saved template and updated files based on that template, and then uploaded files. I still get the error message as I previously posted. – dmwesq Apr 19 '11 at 09:19
0

If you include a local file using SSI, the static source file will be used - in this case, the unparsed PHP source code.

You would have to do a remote include for this to work (something like <!--#include virtual="http://localhost/Navbar.shtml" -->, depending on server configuration). That is not optimal, because a new server request, and a PHP instance, are started.

It would be better to drop SSI for this, and use a PHP include as @Alin shows.

Pekka
  • 442,112
  • 142
  • 972
  • 1,088
0

It should just be a matter of changing your Server side include code to

<?php require "/Navbar.php" ?>

and renaming Navbar.shtml to Navbar.php

Require means that there is an error and the page wont load at all if Navbar.php is missing. You could also use include, which is similar, but will allow the page to load. Read the following manual pages for more info on include and require.

http://www.php.net/manual/en/function.include.php
http://php.net/manual/en/function.require.php

Hope this helps :)

Hjordan
  • 38
  • 4
  • Following error messages received: Warning: require(/Navbar.php) [function.require]: failed to open stream: No such file or directory in /home/troop97/public_html/events.php on line 25 Fatal error: require() [function.require]: Failed opening required '/Navbar.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/troop97/public_html/events.php on line 25 – dmwesq Apr 19 '11 at 09:10
  • Thanks for the quick and timely responses - it was a matter of removing a slash and now it appears to be working. – dmwesq Apr 19 '11 at 09:43