LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-17-2006, 04:17 PM   #1
jdwilder
Member
 
Registered: Jul 2003
Location: United States
Distribution: Fedora Core 7 and older, Knoppix, Ubuntu
Posts: 121

Rep: Reputation: 15
Putting same content on several web pages


I would like to create a web page that has the same disclaimer at the bottom of each page, and the same menu on the left side of each page. I would like a way so that I don't have to copy and paste all the code to each page so that to update the menu or disclaimer I would only have to edit one place and all pages would be affected. I have heard this is possible using css but I cannot find an example anywhere (normally I just view a pages source that does what I want, but the style sheets that a page uses don't show up doing that). I have tried looking at a tutorial but it doesn't cover that.

Thanks for the help.
 
Old 07-17-2006, 04:39 PM   #2
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Hi -

Server side includes are the most common way to do this kind of thing:
http://httpd.apache.org/docs/1.3/howto/ssi.html

Here's a book recommendation: one that'll pay for itself as soon as you get it, and remain a valuable reference for as long as you use it (IMHO):

Teach yourself HTML and CSS in 24 hours, 7th Edition
Dick Oliver, Michael Morrison
http://www.amazon.com/gp/product/067...lance&n=283155

'Hope that helps .. PSM
 
Old 07-17-2006, 04:50 PM   #3
pljvaldez
LQ Guru
 
Registered: Dec 2005
Location: Somewhere on the String
Distribution: Debian Wheezy (x86)
Posts: 6,094

Rep: Reputation: 281Reputation: 281Reputation: 281
I know you can do this using frames, but it's been a long time. With CSS, I've had to copy the actual text onto each page. But the formatting of that text is what is controlled by CSS. Hmmm....

Maybe try to use server side includes?
 
Old 07-17-2006, 05:29 PM   #4
AdaHacker
Member
 
Registered: Oct 2001
Location: Brockport, NY
Distribution: Kubuntu
Posts: 384

Rep: Reputation: 32
Quote:
Originally Posted by jdwilder
I have heard this is possible using css but I cannot find an example anywhere
It is possible to add generated content using the CSS :before and :after pseudo-elements. You would do that like this:
Code:
p#someid:after { content: "This is some text" }
However, you don't really want to use them for this. For starters, not all browsers support :before and :after. Internet Explorer, in particularly, will completely ignore these. Second, they're somewhat limited in the content they can display. They're really not geared toward displaying meaningful text. You'd be much better off with SSI or some very simple PHP includes.
 
Old 07-17-2006, 05:47 PM   #5
tgo
Member
 
Registered: Dec 2004
Posts: 125

Rep: Reputation: 15
I assume posting on a linux forums you would be using php which would make this very easy. When I used to make websites I would have a header.php and a footer.php.

The header would have the title and the top table and the left side table. The footer would have the right column and the footer. So each page would look like
Code:
<?php

include("header.php");
 
// code specific to page here

include("footer.php");

?>
then when you edited header or footer.php it was changed on each page.
 
Old 07-17-2006, 07:04 PM   #6
jdwilder
Member
 
Registered: Jul 2003
Location: United States
Distribution: Fedora Core 7 and older, Knoppix, Ubuntu
Posts: 121

Original Poster
Rep: Reputation: 15
actually I haven't used php, how similar is it to JSP? Where could I find a good online tutorial? I think that is what I will try.
Thanks
 
Old 07-17-2006, 07:23 PM   #7
pljvaldez
LQ Guru
 
Registered: Dec 2005
Location: Somewhere on the String
Distribution: Debian Wheezy (x86)
Posts: 6,094

Rep: Reputation: 281Reputation: 281Reputation: 281
I just fiddled around with server side includes and CSS. It's really easy (and Fun). You can just put the text for your list into a file and call it from within your html.

For example, your file, navbar.ssi would be the following
Code:
<ul>
<li><a href="pathtofile1.html">1st link</a></li>
<li><a href="pathtofile2.html">2nd link</a></li>
<li><a href="pathtofile3.html">3rd link</a></li>
</ul>
Then in your html (index.shtml), you put
Code:
<!--#include virtual="path/to/navbar.ssi" -->
If you're creating the site from scratch, rename your files .shtml (the webserver typically won't parse html files for SSI instructions). If you have to redo a site, there's something called the XBitHack that causes the server to parse regular html files for SSI instructions only if the execute bit is set (i.e. chmod +x index.html). Then you can control the format of the page from your CSS file and keep a separate navbar and footer. Maybe put all the common stuff in a single directory like "include". Then you know where it all is to edit.

Last edited by pljvaldez; 07-17-2006 at 07:24 PM.
 
Old 07-17-2006, 11:31 PM   #8
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Ubuntu 12.04, Antix19.3
Posts: 3,794

Rep: Reputation: 282Reputation: 282Reputation: 282
Look at iframes and objects to do it in plain html.
 
Old 07-18-2006, 08:12 AM   #9
jdwilder
Member
 
Registered: Jul 2003
Location: United States
Distribution: Fedora Core 7 and older, Knoppix, Ubuntu
Posts: 121

Original Poster
Rep: Reputation: 15
Thank you all for the input, I will have time to work on it in a couple of days and it sounds like I will be able to get it going easily enough.
 
Old 07-18-2006, 09:51 AM   #10
henryprince
LQ Newbie
 
Registered: Jul 2006
Posts: 4

Rep: Reputation: 0
i need help

i need help
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
putting dynamic content on desktop spx2 Linux - Newbie 4 12-13-2005 08:12 AM
ADSL Router Web configuration pages appears instead of Personal Web Server Pages procyon Linux - Networking 4 12-20-2004 05:44 PM
some web pages are not web opening in linux emailssent Linux - Networking 4 09-19-2004 06:28 AM
C: How can i print out the content of a file in pages? akin81 Programming 1 03-25-2004 08:46 PM
Can't access Linux web server web pages from LAN client jaydave Linux - Networking 4 03-16-2003 02:38 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:53 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration