Jump to content

Question

Posted

This might be something really easy, but im just not having any success at all. Basically right now, i have been asked by a friend to create a basic information website which will have just text and some images. I have made a css drop down menu which I want to include automatically on every single webpage rather than copy and pasting the code one ach individual page. How can I do this? Does it have to be a php file or can it be html? And also will this only work once its uploaded on a hosting site? or can it work just as a local file on a pc which I double click.

Right now when I create a test page and then do the include tag the page is still blank and does not bring up the menu.html file.

I hope this isnt confusing.

Share this post


Link to post
Share on other sites

5 answers to this question

  • 0

Posted

check out server side includes?

Share this post


Link to post
Share on other sites
  • 0

Posted

You'll need to use a language like PHP to include it on the page. I believe you can do it with HTML5 too using the object tag but you'll lose compatibility among older browsers
You'll also need to have support for that language on your server, also if you're building locally, you'll need to setup a local server for testing.

In PHP it is simple
[code] <?php include_once('filename'); ?>[/code]

Share this post


Link to post
Share on other sites
  • 0

Posted

As they said above, you will need to have something similar to WAMP installed if you're running Windows. Then you will be able to do local PHP development. After you get it together though, it shouldn't be too difficult. Here is how your standard file would be layed out:

[CODE]
<?php
include_once('header.php');
?>
<div id="content">
</div>
<?php
include_once('footer.php');
?>
[/CODE]

'header.php' includes the Doctype, opening html tag, complete head tags, and usually all the code within the body tag that holds your site logo and navigation (usually), and 'footer.php' holds all the code for your site's footer along with the closing body tag and html tag. Having the '.php' extension instead of '.html' will not affect any of your files unless they have PHP code in them. It just informs your server to parse through the code before outputing the document to the client.

Hopefully that clears some things up!

Share this post


Link to post
Share on other sites
  • 0

Posted

what would be the best product to use to test it locally?

sorry just realized you mentioned wamp. Will try it out, what about the standard iis one that comes with windows is that any good? Not sure if its even included win7 anymore.

Share this post


Link to post
Share on other sites
  • 0

Posted

Windows never included a server with their desktop OSes afaik. You can probably use the Windows one if you're on Win Server.

But check out Server Side Includes if you're not doing any actual scripting, it's simpler than making barebones PHP files just for the purpose of using an include function.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0

  • Recently Browsing   0 members

    No registered users viewing this page.