Welcome to WebmasterWorld Guest from 54.161.116.225

Forum Moderators: open

Message Too Old, No Replies

Use of variables in HTML

to facilitate creation of static pages using a template

     
6:18 am on Sep 12, 2003 (gmt 0)

New User

10+ Year Member

joined:Sept 12, 2003
posts:14
votes: 0


Hi all, I'm new to the forum, and to web programming (as my question will show!).

I'm putting up a site with about a hundred static pages based on a single template. A major part of the content variation will involve city names. To save me some work in creating the pages, is there a way to define a variable near the beginning, and then reference this variable throughout the rest of the page?

For example, I might call the variable CITY. The page for Dallas would have code setting CITY equal to "Dallas" near the beginning, and would reference CITY at various places in the content. I would then just need to change this one item for each page I do.

(I know a dynamic structure might seem better suited, but I need to stick with .html pages.)

Thanks!

6:22 am on Sept 12, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member nick_w is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Feb 4, 2002
posts:5044
votes: 0


Hi, and welcome to WebmasterWorld!

HTML can't do that, it was never designed to but you can do it easily with PHP (a server side programming language).

You'd need to define that variable somewhere though and decide on page where and under what conditions to show it. Unfortunately, you have a lot of reading to do ;)

Try [php.net...] for a beginners tutorial and good luck!

Nick

11:56 am on Sept 12, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member korkus2000 is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Mar 20, 2002
posts:3732
votes: 0


You can do it using Javascript and document.write the variable, but Nick's suggestion of server-side scripting. Javascript can be turned off and search engines cannot read it. That makes the solution of populating content with it unappealing.
12:36 pm on Sept 12, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:May 14, 2002
posts:1192
votes: 0


I use a preprocessor on my PC to expand macros and do file inclusions locally. Largely a matter of taste.

I come from the world of UNIX, where pre-processing is a standard procedure. When starting to develop my web site I was searching for a way to include files and found a FAQ answering the question How do I include one file in another? [htmlhelp.com]. The main point was:

Two popular ways of including the contents of one file seamlessly into another for the WWW are preprocessing and server-side inclusion. A preprocessor converts its source into a plain HTML document that you publish on your server. In contrast, documents that use server-side inclusion are processed every time the document is retrieved from the server.

I use a free preprocessor called GTML (G comes before H :) ) written in perl and am very happy with it. There are very many similar products available, it does help to think like a programmer if you use any of them :)

 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members