I have a global CSS file that is linked across all pages, but in my
header comp I look at the requested .html page and see if there is also
a matching .css file of the same name. If so, I include that CSS
content within a <style type="text/css"></style> block within that
specific page's header.
I try to keep the use of these page-specific CSS files to a minimum,
though, because one nice aspect of CSS is that you can cache the global
CSS file(s). Serving page-specific CSS rules with every page serve is
inelegant but sometimes useful (for example when conditionally creating
a CSS rule using Mason).
An example of this is harderco.com. If you look at a given page's
source, you'll see some CSS rules in the header that have been
conditionally included when my handler recognized the matching CSS
file. I do the same with JavaScript (global file and some page-specific
includes handled in the header code).
More recently, I'm moving away from that technique as much as possible
and putting all CSS (global and page-specific) into the global CSS
file. I handle the issue of ensuring unique names by alway embedding my
page-specific CSS within a uniquely-named DIV on each page. So:
#all { global rule }
#login .button { page-specific... I wrap my entire login page into a DIV
with id="login" }
Thus a .button on another page is protected from this rule.
This gives me the benefit of caching and an easy way to avoid
page-specific CSS naming conflicts.
In my autohandler I also ensure my CSS and JS pages are cached and my
HTML pages not cached. Something like:
$r = $m->apache_req;
$file_suffix = ( put your regex here );
$r->content_type( 'text/' . ( ( $file_suffix eq 'js' ) ?
'javascript' : $file_suffix ) . '; charset=utf-8' );
if ( $file_suffix eq 'html' ) {
$r->no_cache( 1 );
}
else {
$r->header_out( 'Cache-Control', "max-age=" . 86400 );
}
Jim Babcock wrote:
Right,
But part of the point of css is to get away from the evil dreadnaut of using
tables to format pages... or at least if you believe the propagada you get from
any css book or website. And I like the idea that I can rearrange my pages, for
the most part, without tearing apart html and recoding it. With a little
thought and some work with divs and spans, you can have all kinds of fun.
BTW, the multiple css references stems from when I had each component calling
its own file, but that didn't seem to work... though it could have been a
complication of the tag closing issue I was having... though I'm still not sure
if all the components should have their own headers and bodies, ie: be complete
and correct html documents, or should just be only the needed code and assume
the highest level doc has the proper structure.
Thanks,
Jimbus
----- Original Message -----
From: "Doug Dawson" <[EMAIL PROTECTED]>
To: "Jim Babcock" <[EMAIL PROTECTED]>
Subject: Re: [Mason] newbie question2: Does Mason play nicely with CSS
positioning?
Date: Tue, 28 Feb 2006 15:55:39 -0600
Here is how I understand Mason (which may be wrong; more experience
people, jump on in):
You shouldn't need all those style sheets, unless you really want them.
One sheet can be used by all your "chunks" because the CSS stuff is used
after Mason has assembled the HTML and delievered it to the client.
So, my autohandlers tend to look like this:
=================
<& header.html &>
<& navigation.html &>
<table border="0" cellpadding="0" cellspacing="0" width="700">
<tr>
<!-- Main Content -->
<td width="520" valign="top">
% $m->call_next;
</td>
<td width="25"><img src="/images/spacer.gif" width="25"
height="1"></td>
<!-- Side Bar -->
<td width="155" valign="top">
<& side_bar.html &>
</td>
</tr>
</table>
<& footer.html &>
=================
My header contains my opening HTML tags, META tags, stylesheet link,
title, etc. Then, I have a navigation "chunk" that contains only a table
with some images with links.
I start a content table that will be reused on all the pages and do the
call_next method.
Then, there is a side_bar page with just a table and some banners.
Finally, the footer contains copyright info and my closing HTML tags.
Each page of content then created by chaining index files from
subfolders with partial HTML in them with the autohandler and the other
components.
Now, when I edit these components in Dreamweaver individually, I can't
see the styles, so I temporaily link to the stylesheet for editing and
then remove the link later.
Does that help at all?
Jim Babcock wrote:
Hopefully I'm not annoying anyone yet...
I took a plain HTML page layout that I built in logical chunks
and postioned using CSS position:absolute. It basically had a
header across the top with a logo, title and search field in the
l, c and r postions; a menu that went 100% wide below it; empty
space for content; then a footer 80% down from the top.
I added mason to the server and broke the page into header.html,
menu.html, footer.html and called them all from autohandler. Now
things are all mushed together. the fonts and sizes and centers
are right, so I know I'm hitting the css sheet correctly...
The autohandler is below:
Jimbus
<html>
<head>
<link rel="stylesheet" type="text/css" href="/resources/css/index.css" />
<link rel="stylesheet" type="text/css" href="/resources/css/menu.css" />
<link rel="stylesheet" type="text/css" href="/resources/css/header.css" />
<link rel="stylesheet" type="text/css" href="/resources/css/footer.css" />
<script type="text/javascript" src="/resources/js/menu.js"></script>
<title>NEOps: </title>
<title>NEOps: <& SELF:title &></title>
</head>
<body>
<& header.html, %ARGS &>
<& menu.html, %ARGS &>
% $m->call_next;
<& footer.html &>
</body>
</html>
<%method title> Network Engineering and Operations </%method>
--
___________________________________________________
Play 100s of games for FREE! http://games.mail.com/
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid0944&bid$1720&dat1642
_______________________________________________
Mason-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mason-users
--
Doug Dawson
Application Developer
Physicians Mutual Insurance Company
(402) 930-2432
UNIX is user friendly, it's just picky about who its friends are.
____________________________________________________________
This message and any attachments are confidential, may contain
privileged information, and are intended solely for the recipient
named above. If you are not the intended recipient, or a person
responsible for delivery to the named recipient, you are notified
that any review, distribution, dissemination or copying is
prohibited. If you have received this message in error, you should
notify the sender by return email and delete the message from your
computer system.
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Mason-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mason-users