Forum Moderators: mack

Message Too Old, No Replies

Easily updating content on all pages

How to update one part of all pages on your site

         

harrybailey

11:01 am on Sep 20, 2003 (gmt 0)

10+ Year Member



I taught myself HTML a while back and now I'm in the process of learning PHP.
I am just redesigning my website and want to be able to update the menu, and it's links on all pages while only having to do the minimum of work.

From my past in HTML I know I could do this using frames or iframes, but to tell you the truth I dislike them a great deal.

Is there another way of doing it? Can I call code for the menu from another file which would update all pages?
Which language would I need to learn?

Any help would be grately apprechiated.

Harry

ulstrup

12:04 pm on Sep 20, 2003 (gmt 0)

10+ Year Member



Welcome to WebmasterWorld!

Is there another way of doing it? Can I call code for the menu from another file which would update all pages?

There sure is a way to do that in PHP, in ASP you use an include file run serverside.

I use MS FrontPage and plain HTML, in FP there is a feature called Include, so you just place the Include file in cell and build your pages using the "Save as" feature, very easy, very simple.

I'm quite sure most people here will encourage you to keep on learning PHP and will provide at method of using Include files in PHP.

Hope this helps, hang around and you will find the answer to allmost any question here at WebmasterWorld.

aus_dave

12:12 pm on Sep 20, 2003 (gmt 0)

10+ Year Member



You can use server side includes (SSI) in straight HTML pages on Unix-based systems. There are a few different ways to do it and a search of this site on SSI would yield plenty of background information for you :).

harrybailey

12:20 pm on Sep 20, 2003 (gmt 0)

10+ Year Member



Thanking you kindly.

jatar_k

6:45 pm on Sep 20, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



The PHP method is to use
[ca.php.net...]

you would then ahve code like so

<?
include "/path/to/sidemenu.php";
?>

on every page.If your pages all presently presently have html extensions you could enable php parsing for html files by using .htaccess and putting something similar to this

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

also see here
[httpd.apache.org...]

Another good thread for some ideas is
A dynamic site in 2 minutes [webmasterworld.com]

harrybailey

11:07 pm on Sep 21, 2003 (gmt 0)

10+ Year Member


Ok Brilliant. I have it all working but now I have another question.
If I am placing an external page (http://somesite.com etc.) into one of the 'include' tags. IE placing external content onto part of a page, how do I script it.

I tried

<?php
include ("http://somepage.com/blah.php");
?>
and
<?php
include "http://somepage.com/blah.php";
?>
and
<?php
include 'http://somepage.com/blah.php';
?>
and even tried the HTML
<!--#include virtual="http://somepage.com"-->

All of the above bring up the text of the page in the correct place but the page attempts to call all images from
http://mysite.co.uk/pictures/pic.jpg etc
instead of
http://somesite.com/pictures/pic.jpg

Help please. How do I make the pictures come from the other root file instead of it trying to get them from mine?

aus_dave

12:04 am on Sep 22, 2003 (gmt 0)

10+ Year Member



Depnds on your server configuration but it's usually the full path to the file e.g. on a virtual host:

<?php
include("/home/username/public_html/header.htm");
?>

Hope this helps :).

aus_dave

3:47 am on Sep 22, 2003 (gmt 0)

10+ Year Member



Just re-read your question - my reply probably won't help you! I think you would have to hard code all the image links to get this to work.

g1smd

10:29 pm on Sep 22, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Just to recap what the include does.

It builds the page up from the various HTML and content fragements scattered through all the text files. The page is then served to the browser.

The browser only sees raw HTML code and your content within that. The page looks no different to one that is a static page that could be served instead. the browser sees all the links as relative to the current page URL, not relative to the location of any of the HTML fragments, because the browser has no idea that the page is even made up of fragments.

Code your links as being relative to the main page location. Use the full URL if pages are offsite from the "main" part of the page.