How to make part of a page dynamic so any updates apply across the whole site

  • Thread starter Thread starter Jet
  • Start date Start date

Jet

Jet

Soldato
Joined
19 Oct 2004
Posts
2,952
Location
Newcastle
Basically what I want to do is have a section on a web page that i can edit separately and when I make changes these will be reflected on every page of the site.

I.e. I have a top contributor table in the sidebar. As it stands, everytime I need to change this table I have to change it on every page of the site which will take ages. I want to be able to edit the table and then when uploaded the changes will be reflected on all of the pages of the site. Make sense?

My knowledge is limited to HTML and CSS, so no PHP or anything.

Is this easy to do? Is there a guide anywhere? I don't even know what to search for really.

Thanks in advance.
 
My fault. When I mentioned my knowledge it was purely so people could keep the replies simple.

If the best way of doing it is php or whatever then so be it. I was just looking for some background info on how you guys would do it.

If you guys could explain how (broadly) you would do it I can look further into it myself. I'm not averse to learning new things.
 
I'd probably use a PHP include for that type of thing:

Code:
<?php include("myfile.html"); ?>

In myfile.html you'd have all the content which you want to include :)

Jon
 
You can do it in shtml files with a server side include

Firstly change all your html files to shtml files. This doesnt do anything bar perhaps break a few links then make a page which has your content in which you want to display on multiple pages. Lets say its called topcontributor.html

Then on each page enter the following code in the place you want it to go;

Code:
<!--#include virtual/topcontributor.html" -->

Have a go at it and report back and we can help you out if youve gone wrong anywhere
 
Either of the above methods is fine, it just depends what your web hosting supports. If there's no PHP then obviously a server side include like fini's example is the most obvious way.
 
You can do it in shtml files with a server side include

Firstly change all your html files to shtml files. This doesnt do anything bar perhaps break a few links then make a page which has your content in which you want to display on multiple pages. Lets say its called topcontributor.html

Then on each page enter the following code in the place you want it to go;

Code:
<!--#include virtual/topcontributor.html" -->

Have a go at it and report back and we can help you out if youve gone wrong anywhere

You shouldn't need to change the extension from *.html on most hosts, try it without first.
 
To be fair it would only entail whacking .php on the end of each page [instead of .html] and putting in that one line of code.

As long as his hosts supports PHP it's sorted.

If he is not averse to learning new things, he might even learn how to dynamically create the table ;)

That said, if your host doesn't support PHP [or you don't fancy using it] then the SSI is the way to go.
 
Thanks for the replies guys.

I'm with tsohost and I'm 98% sure they support php.

I'm off out to watch the Newcastle match but I'll try what you guys have suggested and report back if I run into trouble.

Thanks again.
 
With HTML and CSS alone the only thing I can think of is an include.

<!--#include virtual="insertthisfile.html" -->

Sorry to hijack the thread guys but i'm currently making a website for some coursework and this would be handy. But i'm wondering where i could put it...

Can i put that inbetween some DIV tags and it'll load the page in for me?
 
Not to put too fine a point on it, but stick it wherever you please. :p

If its not working when you try it out - its not supposed to! It's server side so won't work locally.
 
It's only gone and bloody worked!

Thanks so much. This is easily the coolest thing I've done since learning web design and who knew it would be so simple.

And to top it all off Newcastle got a good result.

Awesome.

Edit: last question. For web design I use skEdit and after changing the the end of the filename to .php I can no longer preview it locally. Is the solution to simply keep it as .html until everything is finished and then adding .php?
 
Last edited:
Back
Top Bottom