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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
06-05-2006, 07:16 PM
|
#1
|
|
Member
Registered: Jul 2003
Distribution: OpenSuse 10, Debian
Posts: 152
Rep:
|
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
|
|
|
|
06-05-2006, 07:42 PM
|
#2
|
|
Member
Registered: Sep 2004
Distribution: Debian testing
Posts: 49
Rep:
|
Which do you want to be dynamic- structure or content?
Also, are you using some sort of development tool?
|
|
|
|
06-05-2006, 07:43 PM
|
#3
|
|
Senior Member
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,375
Rep: 
|
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.
|
|
|
|
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,592
|
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 07:49 PM.
|
|
|
|
06-05-2006, 08:56 PM
|
#5
|
|
Member
Registered: Jul 2003
Distribution: OpenSuse 10, Debian
Posts: 152
Original Poster
Rep:
|
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
|
|
|
|
06-07-2006, 12:56 PM
|
#6
|
|
Member
Registered: Jul 2003
Location: CT, USA
Distribution: Debian Sarge (server), Etch (work/home)
Posts: 601
Rep:
|
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.
|
|
|
|
06-07-2006, 01:30 PM
|
#7
|
|
Senior Member
Registered: Mar 2005
Location: USA::Pennsylvania
Distribution: Slackware
Posts: 1,065
Rep:
|
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..
|
|
|
|
06-08-2006, 03:02 AM
|
#8
|
|
Senior Member
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Slackware 10.1/10.2/12, Ubuntu 12.04, Crunchbang Statler
Posts: 3,780
|
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
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting 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
|
|
|
All times are GMT -5. The time now is 12:09 AM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|