Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
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.


  Search this Thread
Old 06-05-2006, 07:16 PM   #1
Registered: Jul 2003
Distribution: OpenSuse 10, Debian
Posts: 152

Rep: Reputation: 30
Web programming dynamic content. I'm confused.

I'm trying to understand how to build web pages so that I don't have to have
the same "page" for every little thing I update or what not.

For example:

I have a basic "template" that my entire site uses. I've got the title and some
navigation links at the top of all my pages, but I have the exact same code in
all of my pages to display the title and nav links.

So if I want to change or add or delete one of the links I have to go through
all the pages and edit each one manually. (Actually I use sed and awk to help
ease my pain but still). Since my site follows the same "look" throughout all
of the pages and only the content of the tables or whatnot change slightly, I
would like to do it in a more dynamic way.

Can someone give me some advice on this?

Thanks for your time.

Old 06-05-2006, 07:42 PM   #2
Registered: Sep 2004
Distribution: Debian testing
Posts: 49

Rep: Reputation: 16
Which do you want to be dynamic- structure or content?
Also, are you using some sort of development tool?
Old 06-05-2006, 07:43 PM   #3
Senior Member
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379

Rep: Reputation: 148Reputation: 148
Some of the look can be incorporated into CSS, but maybe you are already doing that. Since I use php a lot even for simple sites I create my own header and footer and just include them in each page. Then I only need to change the code once to have it reflected throughout the site.
Old 06-05-2006, 07:47 PM   #4
Senior Member
Registered: Jan 2005
Location: Manalapan, NJ
Distribution: Fedora x86 and x86_64, Debian PPC and ARM, Android
Posts: 4,593
Blog Entries: 2

Rep: Reputation: 332Reputation: 332Reputation: 332Reputation: 332
Well, one way to accomplish what you want simply is with SSI - server side includes.

It works like this:

1. In the Apache httpd.conf for the directory, add:

Options Includes

2. Create the file(s) containing the variable content. For example, if you create an "includes" directory in your web document root, you can create an "includes/stuff1.html" file containing a link (or any block of html):

<a href="">the link</a>

3. In your html files, you can then replace the link (or any block of html) with something like:

<!--#include virtual="/includes/stuff1.html" -->

This looks like a comment, but the file specified is inserted at that point in the document, when the document is retrieved.

When you change the include file, then all references are instantly updated.

Last edited by macemoneta; 06-05-2006 at 07:49 PM.
Old 06-05-2006, 08:56 PM   #5
Registered: Jul 2003
Distribution: OpenSuse 10, Debian
Posts: 152

Original Poster
Rep: Reputation: 30
Thanks for your quick replies.

You guys have me looking in the right direction now. I can't believe the daft way I
was going about it before.

Thanks again!

Old 06-07-2006, 12:56 PM   #6
Registered: Jul 2003
Location: CT, USA
Distribution: Debian Sarge (server), Etch (work/home)
Posts: 601

Rep: Reputation: 31
zackarya, the simplest way to start off for you is to extract the marked up text that's common to all pages and put it into a text file.

Then create a cgi script. Have that script open the text file, fill in the bits that are different for a given page, then print out that page.
Old 06-07-2006, 01:30 PM   #7
Senior Member
Registered: Mar 2005
Location: USA::Pennsylvania
Distribution: Slackware
Posts: 1,065

Rep: Reputation: 45
i would agree with graemef on including a header and footer. i also do that. you could also make a function that will print out a certain part of a page (a nav bar for example) when called.

i am also speaking from a php view..

SSI, wow. i almost forgot about SSI. i havent used SSI for 5 years atleast. i think things like php have put the hurts to SSI usage..
Old 06-08-2006, 03:02 AM   #8
Wim Sturkenboom
Senior Member
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Slackware 10.1/10.2/12, Ubuntu 12.04, Crunchbang Statler
Posts: 3,786

Rep: Reputation: 282Reputation: 282Reputation: 282
Depending on the needs, you can also have a look at iframes
<IFRAME SRC="recipe.html" TITLE="The Famous Recipe">
<!-- Alternate content for non-supporting browsers -->
<H2>The Famous Recipe</H2>
Taken from


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Web Content filter jocast Linux - Networking 2 03-20-2006 05:22 PM
putting dynamic content on desktop spx2 Linux - Newbie 4 12-13-2005 08:12 AM
web content filters paul_mat Linux - Software 2 10-11-2005 07:14 PM
Uploading web content by FTP Imanerd Linux - Networking 7 12-15-2004 10:43 PM
PHP - dynamic content jacksmash Programming 11 11-25-2003 02:43 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:27 AM.

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