how to make website wide changes, later

S

someone_else

hi all,
I want to build a website where each page contains a common set of links to
other pages in the site. However, when I add a link, at a later date, I
don't want to have to add it manually to each page.

I have a rudimentary understanding of CSS, but I can't figure out how to use
it to create my basic page template, which contains the common links.

I'm sure I must be missing something very obvious.
Any simple examples out there?
cheers
 
A

Adrienne Boswell

hi all,
I want to build a website where each page contains a common set of
links to other pages in the site. However, when I add a link, at a
later date, I don't want to have to add it manually to each page.

I have a rudimentary understanding of CSS, but I can't figure out how
to use it to create my basic page template, which contains the common
links.

I'm sure I must be missing something very obvious.
Any simple examples out there?
cheers

You want to look into some sort of server side include, depending on
what language your hosting provider has available. For example

<?php include = "nav_inc.php"; ?>
or
<!--#include file = "nav_inc.asp"-->
 
C

Chris F.A. Johnson

hi all,
I want to build a website where each page contains a common set of links to
other pages in the site. However, when I add a link, at a later date, I
don't want to have to add it manually to each page.

I have a rudimentary understanding of CSS, but I can't figure out how to use
it to create my basic page template, which contains the common links.

You don't use CSS; that is for presentation, not content.
I'm sure I must be missing something very obvious.
Any simple examples out there?

Use server-side includes (SSI):

<!--#include file="links.html" -->

You may have to name the enclosing file with a .shtml suffix or set
the execute bit on it, depending on how your web server is set up.
 
S

someone_else

Chris F.A. Johnson said:
You don't use CSS; that is for presentation, not content.


Use server-side includes (SSI):

<!--#include file="links.html" -->

You may have to name the enclosing file with a .shtml suffix or set
the execute bit on it, depending on how your web server is set up.

--
Chris F.A. Johnson, webmaster <http://Woodbine-Gerrard.com>
===================================================================
Author:
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)


Thanks for the quick replies guys.
Since my host does not provide SSI it looks like I will just have to
manually change each page. I can probably create a script in C or perl to
edit the files, but that'll take me longer than manually changing the pages!
Might be a fun project though.
 
J

Jonathan N. Little

Adrienne said:
You want to look into some sort of server side include, depending on
what language your hosting provider has available. For example

<?php include = "nav_inc.php"; ?>

In PHP that's

or
<!--#include file = "nav_inc.asp"-->
 
J

Jonathan N. Little

someone_else said:
Since my host does not provide SSI it looks like I will just have to
manually change each page.

Does host support PHP?
I can probably create a script in C or perl to
edit the files, but that'll take me longer than manually changing the pages!
Might be a fun project though.


Google "html preprocessor"
 
C

C A Upsdell

someone_else said:
Since my host does not provide SSI it looks like I will just have to
manually change each page. I can probably create a script in C or perl to
edit the files, but that'll take me longer than manually changing the pages!
Might be a fun project though.

Or use a text editor that can do a global search and replace.
 
S

someone_else

C A Upsdell said:
Or use a text editor that can do a global search and replace.

I have and old version of Dreamweaver here, and it looks like it does 'block
find and replace' on multiple files .. great! .. I'll give it a try.
 
D

dorayme

"someone_else said:
Since my host does not provide SSI it looks like I will just have to
manually change each page.

In the past when people say this, others here say, get another host.
Because some sort of include is about the only really efficient way to
do this.

Even for me to get the energy to say this I had to have enough cups of
coffee to make a slope prance around like a boistrous monkey.
 
B

Blinky the Shark

someone_else said:
Thanks for the quick replies guys.
Since my host does not provide SSI it looks like I will just have to
manually change each page. I can probably create a script in C or perl to

Free hosting?
 
D

David Segall

Chris F.A. Johnson said:
You don't use CSS; that is for presentation, not content.


Use server-side includes (SSI):

<!--#include file="links.html" -->
How do you make the required changes to distinguish the active menu
item from the remainder? For example, on my site, the menu items have
a class of menuItem but the current page has a class of menuItemActive
in its link. I use CSS to reference the class and highlight the
current item.
 
S

Sitedude

hi all,
I want to build a website where each page contains a common set of links to
other pages in the site. However, when I add a link, at a later date, I
don't want to have to add it manually to each page.

I have a rudimentary understanding of CSS, but I can't figure out how to use
it to create my basic page template, which contains the common links.

I'm sure I must  be missing something very obvious.
Any simple examples out there?
cheers

I see some good input here. Personally I use <!--#include virtual="/
myfolder/myfile.inc"--> however since your host will not allow you to
use the SSI and you would have to change the files to .shtml or .shtm
for that to work. You could get a javascript menu and use that or you
could use a little trick script like this
//trick jscript
<!--hide from old browsers
document.write ("<a href='http://drcwebs.net/index.html'>Index Page</
a>");
-->
//end trick
In a text editor create a file with your links using the
document.write and save it as something like mylinks.js then place
this code in your html file where you want the links to be <script
language="JavaScript" SRC="http://mysite.com/myjsfolder/mylinks.js"
type="text/javascript"></script>
It's a little down and dirty but I got it to work on my local server
good luck with it hope it helps
 
D

dorayme

David Segall said:
How do you make the required changes to distinguish the active menu
item from the remainder? For example, on my site, the menu items have
a class of menuItem but the current page has a class of menuItemActive
in its link. I use CSS to reference the class and highlight the
current item.

You can do like this in the include:

<li<?php if ($thisPage=="index") echo " id=\"currentpage\""; ?>
class="name"><a href="index.html">Home</a></li>

And have the pages marked at the top of the doc type with such as:

<?php $thisPage="index"; ?>

and, of course, styles for "name"

There is likely more elegant, but this works to do distinguishing things
with the current navigational item.
 
R

rf

//trick jscript
<!--hide from old browsers

This idea of HTML comments inside script elements is to correct a bug in
IIRC Netscape version 2 which is now totally obsolete, and that was only for
script elements in the document, not for script residing in an external
file.

Please don't suggest that anybody use this cargo cult stuff in this century.
document.write ("<a href='http://drcwebs.net/index.html'>Index Page</

Which will not work for somewhere between 10 and 15 percent of visitors.
Even if we are lenient and say only 8% of visitors don't have javascript
available or enabled then this is the equivalent of turning your server off
for about one month during the year. And for something as mission critical
as a menu to access other pages on the site is unforgivable.

In addition your most important visitor, googlebot, will be totally unable
to index the site.

The correct way to do this is server side, using SSI or some scripting
language such as PHP, the latter giving the added benefit of having the
"link" to the current page "disabled". If the current host does not support
PHP then there is another one just up the road that does.
 
S

Sitedude

This idea of HTML comments inside script elements is to correct a bug in
IIRC Netscape version 2 which is now totally obsolete, and that was only for
script elements in the document, not for script residing in an external
file.

Please don't suggest that anybody use this cargo cult stuff in this century.


Which will not work for somewhere between 10 and 15 percent of visitors.
Even if we are lenient and say only 8% of visitors don't have javascript
available or enabled then this is the equivalent of turning your server off
for about one month during the year. And for something as mission critical
as a menu to access other pages on the site is unforgivable.

In addition your most important visitor, googlebot, will be totally unable
to index the site.

The correct way to do this is server side, using SSI or some scripting
language such as PHP, the latter giving the added benefit of having the
"link" to the current page "disabled". If the current host does not support
PHP then there is another one just up the road that does.

I suppose you are correct about the html comment. Old habits are hard
to break sometimes and I forgot to mention the <no script> tag should
be used or the W3C validator will complain. If the host will not
enable SSI then they are probably too cheap to support php. The best
advice is to find another host and do this task properly .
 
R

richard

I see some good input here. Personally I use <!--#include virtual="/
myfolder/myfile.inc"--> however since your host will not allow you to
use the SSI and you would have to change the files to .shtml or .shtm
for that to work. You could get a javascript menu and use that or you
could use a little trick script like this
//trick jscript
<!--hide from old browsers
document.write ("<a href='http://drcwebs.net/index.html'>Index Page</
a>");
-->
//end trick
In a text editor create a file with your links using the
document.write and save it as something like mylinks.js then place
this code in your html file where you want the links to be <script
language="JavaScript" SRC="http://mysite.com/myjsfolder/mylinks.js"
type="text/javascript"></script>
It's a little down and dirty but I got it to work on my local server
good luck with it hope it helps


And just how will javascript make the changes across the entire site?
Your code would have to be placed on every page.
Then what if I have JS turned off?

Your idea would be much better served in PHP.
 
R

rf

I suppose you are correct about the html comment. Old habits are hard
to break sometimes

Even after more than a decade? :)
and I forgot to mention the <no script> tag should

be used or the W3C validator will complain.

No it won't.

And, sadly, the most common use of the noscript element is to proclaim
something like:
If the host will not
enable SSI then they are probably too cheap to support php. The best
advice is to find another host and do this task properly .

Indeed.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,996
Messages
2,570,237
Members
46,825
Latest member
VernonQuy6

Latest Threads

Top