 |
 |
Best way to replicate content on several pages?
|
 |
|
 |
|
Junior Member
Join Date: Nov 2003
Location: Portland, Oregon
Status:
Offline
|
|
I am maintaining a couple of web sites - each with about 20 pages of similar look. Many times I find myself having to make a change 20 times in order to keep all the pages looking the same.
I'm not sure what application was originally used to create these pages - that application probably had some sort of template mechanism to keep from having to edit all the pages to make change affecting all the pages.
I have thought of a couple possible choices:
1) Start totally from scratch and use a web publishing software with templates again. (I don't like this option as it locks me into that application and I have to fight with their templates.)
2) Look for a way to "include" common files into my HTML files. I've looked long and hard for how to do this and the only thing I've found so far is an include directive to the Apache web server. This is attractive. It does limit me to Apache web servers (which I'd probably stay with anyways.)
3) Use JaveScript functions (preferably) or PHP functions (if convinced) to generate the common portions of the pages. Then call these functions in each of the pages. This is kind of attractive in that I could pass arguments and have slight differences on different pages.
Am I missing something? Is there another way? I keep hoping there is a simple C-Like #include <somefile.html> directive I could use.
I'd like to hear how others deal with this problem. Although I like to edit code directly, and use either vi or BBEdit to do so, I also find myself yearning for a Dreamweaver application. Demo'ing it now. Also demo'ing Contribute for my client to use. So whatever solution I pick probably needs to work with both of these.
Erik
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Mar 2002
Location: Clogland
Status:
Offline
|
|
I use php, as in......
<?php
include ("header.php");
include ("includes/content.php");
include ("footer.php");
?>
|
|
|
| |
|
|
|
 |
|
 |
|
Occasionally Useful
Join Date: Jun 2001
Location: Liverpool, UK
Status:
Offline
|
|
Originally posted by bitjumper:
2) Look for a way to "include" common files into my HTML files. I've looked long and hard for how to do this and the only thing I've found so far is an include directive to the Apache web server. This is attractive. It does limit me to Apache web servers (which I'd probably stay with anyways.)
i don't think Apache is going to be a major problem for you:
Originally posted on the Apache web site :
Apache has been the most popular web server on the Internet since April of 1996. The October 2003 Netcraft Web Server Survey found that more than 64% of the web sites on the Internet are using Apache, thus making it more widely used than all other web servers combined.
you can do it like this:
<!--#include virtual="header.html" -->
<!--#include virtual="includes/content.html" -->
<!--#include virtual="footer.html" -->
just make sure you save it as as .shtml file.
you can also include perl applications in this way too, with either of these, depending on how tightly the server is locked down:
<!--#exec cgi="/cgi-bin/zilla.pl" -->
<!--#include virtual="/cgi-bin/zilla.pl" -->
|
|
"Have sharp knives. Be creative. Cook to music" ~ maxelson
|
| |
|
|
|
 |
|
 |
|
Dedicated MacNNer
Join Date: Sep 2002
Status:
Offline
|
|
Those directives are actually SSI (Server Side Include) directives, and so shouldn't be unique to apache anyway. I think SSI should be at least as portable as PHP - possibly more so, since PHP can open up security holes more easily (I don't think SSI can, if the exec commands are disabled).
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Mar 2003
Status:
Offline
|
|
check out the cool stuff you can do with CSS
http://www.csszengarden.com/
And they way you can keep static pages and when you go to edit the pages all you have is content.
I am in the middle of getting something going at my website www.truepop.com I use pMachine Pro but the entire layout is down with layers and CSS. www.truepop.com/test/ (kind of rough right now)
I have a lot of good links for if you want to take the css way.
|
|
|
| |
|
|
|
 |
|
 |
|
Grizzled Veteran
Join Date: Nov 2003
Location: Hebburn, UK
Status:
Offline
|
|
Originally posted by Truepop:
check out the cool stuff you can do with CSS
http://www.csszengarden.com/
And they way you can keep static pages and when you go to edit the pages all you have is content.
I am in the middle of getting something going at my website www.truepop.com I use pMachine Pro but the entire layout is down with layers and CSS. www.truepop.com/test/ (kind of rough right now)
I have a lot of good links for if you want to take the css way.
I think he was asking about including content rather than CSS e.g. including some php file which prints out a sidebar or something that is common to all the pages on a site. Although this may include
Code:
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"something.css\" />";
I am presuming it's not what he meant.
Don't know why I posted this, since all it does is say that you wasted your time, but I thought I might as well... it's what a few pints of McCartney's does to you, I suppose. 
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Mar 2003
Status:
Offline
|
|
sorry. I thought he meant change design since he was talking about templates, dreamweaver, and Contribute.
|
|
|
| |
|
|
|
 |
|
 |
|
Senior User
Join Date: Apr 2001
Location: Palo Alto, CA
Status:
Offline
|
|
Easiest way is by coding in xhtml, keeping all your design confined to css and using dreamweaver templates.
But you say you don't want to do the template thing so the next best way to do this is with php... again mainly code in xhtml and keep all your design elements defined in css... you'll spend more time creating your php than you would with a dreamweaver template, but once you're done it's just a question of plugging in data...
|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|