LinuxQuestions.org
Help answer threads with 0 replies.
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 06-05-2006, 08:16 PM   #1
zackarya
Member
 
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.

Zackarya
 
Old 06-05-2006, 08:42 PM   #2
rjtucke
Member
 
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, 08:43 PM   #3
graemef
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, 08:47 PM   #4
macemoneta
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: 328Reputation: 328Reputation: 328Reputation: 328
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="http://someserver.com/some.html">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 08:49 PM.
 
Old 06-05-2006, 09:56 PM   #5
zackarya
Member
 
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!

Zackarya
 
Old 06-07-2006, 01:56 PM   #6
johnMG
Member
 
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, 02:30 PM   #7
xhi
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, 04: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
Code:
<IFRAME SRC="recipe.html" TITLE="The Famous Recipe">
<!-- Alternate content for non-supporting browsers -->
<H2>The Famous Recipe</H2>
<H3>Ingredients</H3>
...
</IFRAME>
Taken from http://www.htmlhelp.com/reference/ht...al/iframe.html
 
  


Reply


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 06:22 PM
putting dynamic content on desktop spx2 Linux - Newbie 4 12-13-2005 09:12 AM
web content filters paul_mat Linux - Software 2 10-11-2005 08:14 PM
Uploading web content by FTP Imanerd Linux - Networking 7 12-15-2004 11:43 PM
PHP - dynamic content jacksmash Programming 11 11-25-2003 03:43 PM


All times are GMT -5. The time now is 02:55 PM.

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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration