A way to edit content by modifying a single file?
I have a css contact tab on the left side of my website, I have over 30 pages and I don't want to manually modify all of these pages later when the data has changed. Does anyone know a solution so I only need to change one file to edit all pages?
Perhaps in javascript?
Below is the code for the tab
<div class="slide-out-div">
<a class="handle" href="http://link-for-non-js-users">Content</a>
<h3>Onze contact gegevens</h3>
<p>Adres: van Ostadestraat 55<br />
Postcode: 8932 JZ<br />
Plaats: Leeuwarden<br />
Tel: 058 844 66 28<br />
Mob: 0629594595
<br />
E-mail: <a href="mailto:info@friesecomputerservice.nl">info@friesecomputerservice.nl</a><br /><br />
</p>
<p>Mocht u vragen hebben dan kunt u gerust bij ons terecht voor meer informatie.</p>
Edit:
This is in my html
<!--#include virtual="contact.txt" -->
</body>
and this is in my contact.txt, which is rotting in my web folder:
<div class="slide-out-div">
<a class="handle" href="http://link-for-non-js-users">Content</a>
<h3>Onze contact gegevens</h3>
<p>Adres: van Ostadestraat 55<br />
Postcode: 8932 JZ<br />
Plaats: Leeuwarden<br />
Tel: 058 844 66 28<br />
Mob: 0629594595
<br />
E-mail: <a href="mailto:info@friesecomputerservice.nl">info@friesecomputerservice.nl</a><br /><br />
</p>
<p>Mocht u vragen hebben dan kunt u gerust bij ons terecht voor meer informatie.</p>
a source to share
You might want to use Server Side Includes (SSI).
You put a piece of code in a separate file, for example contact.txt
, and then simply link to it across all your 30 pages using:
<!--#include virtual="contact.txt" -->
SSI is supported by all popular web servers including Apache, IIS, and lighttpd.
a source to share
Create a text file with the appropriate HTML / text and place it in your HTML where you want it to appear.
<!--#include virtual="path to file/include-file.txt" -->
Hope that helps :)
UPDATE:
After lengthy discussion, rename your pages to .php instead of .html and your contact to .php instead of .txt and use this to include your file:
<?php include('contact.php'); ?>
If your pages are in different directories then use:
<?php include($DOCUMENT_ROOT . "/path-to-files/contact.php"); ?>
This will make the page look at your site's root directory.
a source to share
As suggested, you can use Apache SSI. It depends on which specific web server and module used.
To achieve this result, you can either do two things:
Use some templating language that supports it and "compile" it before uploading it to your web server. Using Ruby ERB is one example.
Another is to use a server side programming language (I would recommend PHP as it is simple, easy to deploy and a lot of documentation around) to do this for you on the server.
Here's a simple example using PHP: http://www.albinoblacksheep.com/tutorial/include
a source to share
How I make Daniel and Kyle's decisions (and I +1 their answers)
If I were in your situation. I put together the html with your contact information and then included it with a border on 30 other pages like
- contact.html (which only includes contact information)
- page1.htm
- pagex.htm
- page30.htm
and in one page x.htm put the following code
<body>
Other part of page ....
<iframe id="contact" src="../contact.htm"></iframe>
</body>
a source to share