473,469 Members | 1,535 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Inserting a variable in a stylesheet.

I am in the process of converting a page with nested tables to CSS. The
current page is at http://www.douglaidlaw.net./boykett/history.html. So
far, it is using a page-wide stylesheet to set fonts only.

I want this page to be followed by others with identical layout for
successive "chapters." In each page, I would like a different image to
replace the overworked silhouette. For example, in the next page, I would
like to have photos of Thomas' office building, then and now. So they will
be not only different from Page 1, but different from each other.

How can I handle that with a stylesheet? Rather than do away with tables
altogether, as a first stage, I would prefer to move the table structure to
a site-wide stylesheet. All pages use the same basic structure. I would
need something like IMG1 and IMG2 in the stylesheet, and the URLs stated in
the individual page.

Thanks,

Doug
--
Registered Linux User No. 277548. My true email address has hotkey for
myaccess.
Never let your sense of morals get in the way of doing what's right.
- Isaac Asimov.

Jan 12 '06 #1
3 1375

Doug Laidlaw wrote:
In each page, I would like a different image to
replace the overworked silhouette. How can I handle that with a stylesheet?


If you have server-side scripting (e.g. PHP or Perl or JSP or ASP)
available then you could generate stylesheets dynamically, for instance
passing in the image URL in the query string e.g.
<link rel="stylesheet"
type="text/css"
href="stylesheet.php?img=image1.gif">
and then generating the CSS you want to serve.

There is nothing you could do directly in a static stylesheet as CSS
does not allow you to have variables which a user agent would substitute
as needed.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jan 12 '06 #2
On Thu, 12 Jan 2006 14:52:28 +1100, Doug Laidlaw
<la******@myaccess.com.au> wrote:
I want this page to be followed by others with identical layout for
successive "chapters." In each page, I would like a different image to
replace the overworked silhouette.


You need to apply different fragments of a stylesheet to each group of
pages.

There are two ways to do this - take your pick.

One is to have n+1 stylesheets. Each page links in the "common"
stylesheet, then after that links in the appropriate "chapter"
stylesheet. The chapter stylesheet has only the chapter-specific changes
in it (for robustness, these over-write a safe default that's in the
common stylesheet anyway).

The other way is to have one stylesheet and to give each page a class on
the <body> tag of "chapter1" etc. Then use this in a selector in a
repeated group of similar rules in the common stylesheeet, changign the
value as necessary.

Don't do dynamic things - this isn't a dynamic site. It's easier to do
it as a one-off publishing task, rather than a repeated page-serving
task.
Jan 13 '06 #3
Martin Honnen wrote:

Doug Laidlaw wrote:
In each page, I would like a different image to
replace the overworked silhouette.

How can I handle that with a stylesheet?


If you have server-side scripting (e.g. PHP or Perl or JSP or ASP)
available then you could generate stylesheets dynamically, for instance
passing in the image URL in the query string e.g.
<link rel="stylesheet"
type="text/css"
href="stylesheet.php?img=image1.gif">
and then generating the CSS you want to serve.

There is nothing you could do directly in a static stylesheet as CSS
does not allow you to have variables which a user agent would substitute
as needed.


Thank you, Martin. Yes, I do have PHP. The family tree program itself is
written in PHP. I suppose that I could just leave the image to be put
there by HTML, in a similar fashion to the text block, but I haven't
thought it through.

Doug.
--
Registered Linux User No. 277548. My true email address has hotkey for
myaccess.
No man was ever endowed with a right without being at the same time saddled
with a responsibility.
- Gerald W. Johnson.

Jan 13 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Dennis Westermann | last post by:
I have the following problem XML-File: <SEARCH> <TAG>'x' or 'y'</TAG> </SEARCH> <CHARLIST> <CHAR>a</CHAR> <CHAR>x</CHAR>
1
by: CB | last post by:
I have a group of documents that previously had no schema, now I have a schema, and I want to use XSLT to fixup the documents by inserting the namespace reference. In other words, my input...
5
by: Nagi Peters | last post by:
Hello I try to tranform a XML Document in php/Sablotron with the following XSL Stylesheet. I tried to write "@id='1'" with the variable chapter_id. So it works: <xsl:variable...
2
by: Bradford | last post by:
Question for the masses... Lets say I have variable with the following contents "aaaa bbbb ccccc dddd". The format is not specific and the space delimiter could be changed to any other. How...
4
by: Frederik Sørensen | last post by:
I include a xslt stylesheet with variables for all the error messages in my system. <xsl:variable name="Banner_error_1"> errormessage 1 for banner </xsl:variable> <xsl:variable...
2
by: John | last post by:
I'm new to XSLT and I've been trying to figure out a solution for the last couple of days. The XML & XSLT stylesheet are below. Basically I want to declare some language (English, French, etc.)...
1
by: MC | last post by:
Hi to all, I would like to use in a XSL stylesheet an array variable which is defined in a Java program. For example, in my program, i defined a tab variable String tab = {"first", "second",...
2
by: Jon Martin Solaas | last post by:
Hi, I have a general document somewhat like this: -------------------------------------- <root> <level1> <level2> <interestingstuff number="2"/> <interestingstuff number="3"/>...
6
by: Jody Gelowitz | last post by:
I have run into an issue with variable scope within an XSLT document that is translated in VS.NET 2.0. Under VS.NET 1.1 (XslTransform), this code works fine. However, when using VS.NET 2.0...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.