Please help for building my site with menus and external css

C

coolunmesh

I've designed my site long ago. but the problem is that i've a few
menus in every page. so i need to add the same code for the same menu
in every page except its own link( like no "about me' link in "about me
"page). at the same time i need to put the same css code in evey page.
and the menu is not located at the same place in every page. The menus
in every page is different compared to other websites.

Please help to fix the problem.
 
R

Roy Schestowitz

__/ [ (e-mail address removed) ] on Wednesday 26 April 2006 17:42 \__
I've designed my site long ago. but the problem is that i've a few
menus in every page. so i need to add the same code for the same menu
in every page except its own link( like no "about me' link in "about me
"page). at the same time i need to put the same css code in evey page.
and the menu is not located at the same place in every page. The menus
in every page is different compared to other websites.

Please help to fix the problem.

Hi,

CSS should be peripheral. Several pages can share the same stylesheet and
should do so if they bear a commonality (duplication is always a bad idea),
e.g. include <link rel="stylesheet" href="/styles/yourstyle.css"
type="text/css" /> between <head> and </head>. If you want to add this line
of code to many files in one fell swoop, you could use GNU/Linux tools, e.g.

find . -maxdepth 1 -type f -name '*.html' -print |
while read filename
do # print all filenames
(
sed 's/<head>/<head><link rel="stylesheet"
href="/styles/yourstyle.css" type="text/css" />/i;'
$filename >$filename.xxxxx
mv $filename.xxxxx $filename
# replace output files with original
)
done

The same strategy goes for menus. Menus are better written in a single place,
which makes them easier to change without pattern recognition and mass-file
replacement. If you don't use a CMS, you may wish to add a menu with a
complete set of links and disable individual to-self links manually, page by
page.

Hope it helps,

Roy
 
J

Jim Moe

I've designed my site long ago. but the problem is that i've a few
menus in every page. so i need to add the same code for the same menu
in every page except its own link( like no "about me' link in "about me
"page). at the same time i need to put the same css code in evey page.
and the menu is not located at the same place in every page. The menus
in every page is different compared to other websites.
Put the CSS into a separate file. Add one of these to the <head>:
<link rel="stylesheet" href="/styles/common.css" type="text/css">
or
<style type="text/css">
@import url("/styles/common.css");
</style>

See <http://allmyfaqs.net/faq.pl?Include_one_file_in_another>.
 
N

Neredbojias

To further the education of mankind, (e-mail address removed) vouchsafed:
I've designed my site long ago. but the problem is that i've a few
menus in every page. so i need to add the same code for the same menu
in every page except its own link( like no "about me' link in "about me
"page). at the same time i need to put the same css code in evey page.
and the menu is not located at the same place in every page. The menus
in every page is different compared to other websites.

PHP is made for your situation. The menu(s) template can be made and
adjusted to render each virtual page uniquely based on a variable in the
search string. Google for info about php and includes.
 
T

Toby Inkster

Roy said:
sed 's/<head>/<head><link rel="stylesheet"
href="/styles/yourstyle.css" type="text/css" />/i;'

This will work?! Shoudn't you be escaping some of those slashes?
 
R

Roy Schestowitz

__/ [ Toby Inkster ] on Saturday 29 April 2006 17:22 \__
This will work?! Shoudn't you be escaping some of those slashes?

Oops. You're right. I added some slashes without testing, let alone thinking.
That 'script', by the way, is a derivative of something that /you/ once
wrote in an answer to my question. I have used this for the processing of
thousands of pages over the past year or so, mainly after LaTeX->HTML
conversions. Thanks for that.

Best wishes,

Roy
 
T

Toby Inkster

Roy said:
That 'script', by the way, is a derivative of something that /you/ once
wrote in an answer to my question.

Really? I can't imagine I would have written something as fancy as that as
a shell script. For anything that involves loops and logic, I tend to
immediately switch to Perl.

You might want to look at replacing this:

sed 'script' file >file.xxxxx
mv file.xxxxx file

with this:

sed -i 'script' file

From "man sed":


-i[SUFFIX], --in-place[=SUFFIX]

edit files in place (makes backup if extension supplied)
 
R

Roy Schestowitz

__/ [ Toby Inkster ] on Sunday 30 April 2006 12:14 \__
Really? I can't imagine I would have written something as fancy as that as
a shell script. For anything that involves loops and logic, I tend to
immediately switch to Perl.


With respect, there was nothing overly sophisticated in your previous
suggestion. I just never knew anything about sed. Then you provided me with
a useful, extensible template/example. I needed such a tool for editing
files /en masse/.

http://schestowitz.com/Software/Search_and_Replace/ (it's not "software", but
it didn't fit anywhere else)

You might want to look at replacing this:

sed 'script' file >file.xxxxx
mv file.xxxxx file

with this:

sed -i 'script' file

From "man sed":


-i[SUFFIX], --in-place[=SUFFIX]

edit files in place (makes backup if extension supplied)


Thanks. To be honest, my filthy beast *grin* is doing its work reliably
enough and completes the task within a few seconds. I fear change that
involves subsequent testing, but will keep your kind advice close to hand.

Best wishes,

Roy
 

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,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top