Jump to content



Photo

Including certain file in each webpage


  • Please log in to reply
5 replies to this topic

#1 Soldiers33

Soldiers33

    Neowinian Senior

  • Joined: 01-September 06
  • Location: London
  • OS: Windows 7 Professional

Posted 30 January 2013 - 15:18

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.


#2 primexx

primexx

    Neowinian Senior

  • Tech Issues Solved: 6
  • Joined: 24-April 05

Posted 30 January 2013 - 21:00

check out server side includes?

#3 +Lingwo

Lingwo

    Neowinian Senior

  • Tech Issues Solved: 1
  • Joined: 22-April 03
  • Location: UK

Posted 31 January 2013 - 11:48

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
<?php include_once('filename'); ?>


#4 palenous

palenous

    Neowinian

  • Joined: 19-January 13
  • Location: Ohio, United States
  • OS: Windows 7 Ultimate
  • Phone: Samsung Galaxy SIII (Verizon)

Posted 31 January 2013 - 14:28

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:

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

'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!

#5 OP Soldiers33

Soldiers33

    Neowinian Senior

  • Joined: 01-September 06
  • Location: London
  • OS: Windows 7 Professional

Posted 31 January 2013 - 15:30

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.

#6 primexx

primexx

    Neowinian Senior

  • Tech Issues Solved: 6
  • Joined: 24-April 05

Posted 31 January 2013 - 22:52

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.



Click here to login or here to register to remove this ad, it's free!