[Zope] ZPT and CSS

Michael Havard nhavar at hotmail.com
Sun Nov 30 23:03:53 EST 2003


move your link down into the header macro section and see if it works then. 
I think what might be happening is that your "head" macro is not being 
pulled into the generated page at all. You should be able to view source and 
see if the link is even showing up in the page and if it is if maybe another 
style sheet comes after it that throws things off.

I can say that CSS does work in ZPT because I use it every day.


>From: Andre Meyer <a.meyer at hccnet.nl>
>To: Zope Mailing List <zope at zope.org>
>CC: Tino Wildenhain <tino at wildenhain.de>
>Subject: Re: [Zope] ZPT and CSS
>Date: Sun, 30 Nov 2003 23:48:53 +0100
>MIME-Version: 1.0
>Received: from mc8-f26.hotmail.com ([65.54.253.162]) by mc8-s6.hotmail.com 
>with Microsoft SMTPSVC(5.0.2195.6713); Sun, 30 Nov 2003 14:48:53 -0800
>Received: from mail.python.org ([12.155.117.29]) by mc8-f26.hotmail.com 
>with Microsoft SMTPSVC(5.0.2195.6713); Sun, 30 Nov 2003 14:49:21 -0800
>Received: from localhost.localdomain ([127.0.0.1] helo=mail.python.org)by 
>mail.python.org with esmtp (Exim 4.22)id 1AQaNB-00033g-S5; Sun, 30 Nov 2003 
>17:49:01 -0500
>Received: from smtp.hccnet.nl ([62.251.0.13])by mail.python.org with esmtp 
>(Exim 4.22) id 1AQaN6-00033B-Lpfor zope at zope.org; Sun, 30 Nov 2003 17:48:56 
>-0500
>Received: from [10.0.0.13] by smtp.hccnet.nlvia fia27-95.dsl.hccnet.nl 
>[62.251.95.27] with ESMTPid hAUMmsgt003932 (8.12.10/2.03); Sun, 30 Nov 2003 
>23:48:54 +0100 (MET)
>X-Message-Info: pdGgd64Ckwb64bDCBiLbou2ARrp6rGbVBWG9E59sdxI=
>In-Reply-To: <3FCA3C4A.7070300 at wildenhain.de>
>References: 
><1070188751.13695.4.camel at localhost.localdomain><3FC9EB73.4020703 at wildenhain.de><1070215826.13695.16.camel at localhost.localdomain><3FCA3C4A.7070300 at wildenhain.de>
>Message-Id: <1070232533.13695.20.camel at localhost.localdomain>
>X-Mailer: Ximian Evolution 1.4.5 (1.4.5-7) X-Spam-Status: OK (zopelist 
>0.000)
>X-BeenThere: zope at zope.org
>X-Mailman-Version: 2.1.3
>Precedence: list
>List-Id: Users of the Z Object Publishing Environment <zope.zope.org>
>List-Unsubscribe: 
><http://mail.zope.org/mailman/listinfo/zope>,<mailto:zope-request at zope.org?subject=unsubscribe>
>List-Archive: <http://lists.zope.org/pipermail/zope>
>List-Post: <mailto:zope at zope.org>
>List-Help: <mailto:zope-request at zope.org?subject=help>
>List-Subscribe: 
><http://mail.zope.org/mailman/listinfo/zope>,<mailto:zope-request at zope.org?subject=subscribe>
>Sender: zope-bounces at zope.org
>Errors-To: zope-bounces at zope.org
>Return-Path: zope-bounces at zope.org
>X-OriginalArrivalTime: 30 Nov 2003 22:49:22.0038 (UTC) 
>FILETIME=[321E1160:01C3B794]
>
>Something else must be wrong here.
>
>It works find as long as the style information is inside the zpt page,
>but referring to an external css file does not work for me. I found
>quite some references that this is not possible with zpt, only with
>dtml. Others claim it can be done. What is the secret behind doing this?
>
>
>On Sun, 2003-11-30 at 19:51, Tino Wildenhain wrote:
> > Hi Andre,
> >
> > Andre Meyer wrote:
> > > Dear Tino
> > >
> > > Thanks for your answer. I did indeed expect normal HTML and ZPT/Zope
> > > generate HTML to behave the same. However, when I open the same HTML
> > > file using "Open File..." in Mozilla it displays correctly using the 
>CSS
> > > file which is in the same folder 
>(~/zope/lib/python/Products/mlib/zpt).
> > > When I view this same HTML file through Zope
> > > (http://localhost:8080/music/index_html) it does not use the CSS file.
> > > Viewing both sources in Mozilla reveals that Zope inserts a base tag.
> > > That results in Mozilla not finding the CSS file.
> > > How can this be prevented? Or what is the right way to do it?
> >
> > As I said: you give a full qualified path to the resource,
> > e.g. <link rel="stylesheet" type="text/css" href="/mlib/zpt/mlib.css"/>
> >
> > This is always recommended because Zope is not a regular file based
> > web server but an object publisher!
> >
> > Regards
> > Tino Wildenhain
> >
> > >
> > > Here is what I have so far:
> > >
> > > ~/zope/lib/python/Products/mlib/zpt/index_html.zpt
> > > ==============
> > > <!DOCTYPE html
> > > 	PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
> > > 	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
> > > <html>
> > > 	<head metal:define-macro="head">
> > > 		<link rel="stylesheet" type="text/css" href="mlib.css"/>
> > > 		<title>Music Library</title>
> > > 	</head>
> > > 	<body bgcolor="white">
> > > 		<div metal:define-macro="header">
> > > 			<table border="0" cellspacing="0" cellpadding="6"
> > > width="100%"><tr><td bgcolor="#a0a0ff"><h1
> > > tal:content="here/title_or_id">Title</h1></td></tr></table><br/>
> > > 		</div>
> > > ...
> > > ==============
> > > ~/zope/lib/python/Products/mlib/zpt/mlib.css
> > > ==============
> > > h1
> > > {
> > > 	background-color: yellow;
> > > 	color:  #666699;
> > > 	text-decoration: blink;
> > > }
> > >
> > > table
> > > {
> > > 	background-color: red;
> > > }
> > > ...
> > >
> > > On Sun, 2003-11-30 at 14:06, Tino Wildenhain wrote:
> > >
> > >>Hi Andre,
> > >>
> > >>Andre Meyer wrote:
> > >>
> > >>>Hi Zopers
> > >>>
> > >>>Trying to improve my ZPT pages I wanted to make use of Cascading 
>Style
> > >>>Sheets (CSS). While the styles in my CSS file are properly rendered 
>when
> > >>>I open the HTML file directly in the browser (Mozilla 1.4.1) they
> > >>>completely disappear when I view the same page through Zope!!!
> > >>>What is Zope doing? May it be that the CSS cannot be located because 
>of
> > >>>the base url inserted by Zope?
> > >>
> > >>Beside possible and intended by you manipulations of the HTML
> > >>structure by means of TAL there is no difference between
> > >>The HTML you put in and the HTML you get out.
> > >>
> > >>After all, you can use "view source" in your web browser to check.
> > >>
> > >>As for links to embedded resources (images, scripts, styles)
> > >>you would preferably use root-relative links. That is:
> > >>links starting with /
> > >>Its not because it would not work - since it would work
> > >>with relative links quite well - you avoid multiple
> > >>versions appear in caches because of Zopes
> > >>acquisition.
> > >>
> > >>So, just check what you put in and what you really get back.
> > >>See if the mime-type of your CSS file is correct or
> > >>change it otherwise.
> > >>
> > >>We all use CSS with Zope since its definitively the way to go :)
> > >>
> > >>Regards
> > >>Tino Wildenhain
> > >>
> > >
> > >
> >
> >
>
>
>_______________________________________________
>Zope maillist  -  Zope at zope.org
>http://mail.zope.org/mailman/listinfo/zope
>**   No cross posts or HTML encoding!  **
>(Related lists -
>  http://mail.zope.org/mailman/listinfo/zope-announce
>  http://mail.zope.org/mailman/listinfo/zope-dev )

_________________________________________________________________
Is there a gadget-lover on your gift list?  MSN Shopping has lined up some 
good bets!  http://shopping.msn.com




More information about the Zope mailing list