Jump to content

Recommended Posts

Posted

I'm trying to get an oft-changing navigation bar to appear in my web pages dynamically.

 

The file to be included is called links.htm and resides in the top-level public_html directory. It's a full-blown html file with headers, body tags, everything.

 

The command I'm using to include it is <!--#include virtual="links.htm" -->.

 

I'm testing it in http://www.fairhousingforkerry.org/template.htm, which is in the same directory as links.htm.

 

I added "Options +Includes" to the .htaccess file on my account as well as to a file called .htaccess.1086880578.

 

So it's not working. Can anyone tell me what I'm missing?

 

Thanks,

 

Tracey

Posted

I'm not 100% positive, but don't you have to save the file as a .inc file rather than an htm file? I know at work our includes are named sidenav.inc

Posted

I think the include file can be pretty much whatever you want to call it, as long as it contains HTML code. Your work probably calls it .inc so that it's obvious it's an include.

 

Anyhoo, I got it working - I had to break down and rename all the files .shtml, but now it's fine.

 

Thanks!

Posted

To use the #include directive your pages have to end in .shtml

 

You could use PHP to include content in your .htm and .html documents by adding this line to your .htaccess file.

 

AddType application/x-httpd-php .htm .html

Posted
You could use PHP to include content in your .htm and .html documents by adding this line to your .htaccess file.

 

AddType application/x-httpd-php .htm .html

 

Surely it's not as simple as that, is it? Isn't there a PHP script or app I'd need, or a database?

 

As you can see, I know NOTHING about PHP. :lol:

Posted

That line will tell it to look for php - this is the code to include files:

 

><? include("filename.php") ?>

 

and you can use paths in that too (ie /home/username/public_html/includes/filename.php) if you want.

 

hope that helps. =)

Posted (edited)

And the file that you are including doesn't have to be PHP. You could simply change your virtual include to read and it would work.

 

<?php

include $_SERVER['DOCUMENT_ROOT']."/links.htm";

?>

Edited by TCH-Bruce

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...