[Zope] ZPT and CSS

Andre Meyer a.meyer at hccnet.nl
Sun Nov 30 17:48:53 EST 2003


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
> >>
> > 
> > 
> 
> 




More information about the Zope mailing list