I'd like to use a CSS stylesheet editable within the Zope Management Interface, and refer to it from a LINK tag in the HEAD of each page. I'm just learning Zope, and trying to stick to ZPTs over DTML wherever possible. I searched Zope.org, and found mindlace's post of a "CSS & Zope howto" in 1999. It talks about using the LINK tag to incorporate external CSS that is still an editable Zope object, exactly what I want, but it's a DTML object, and I'm not sure how to replicate this line in a ZPT: From: http://www.zope.org/Members/mindlace/css_zope ---------------------------------------------- IMPORTANT: You must have the following line as the first line of your method: <dtml-call "RESPONSE.setHeader('Content-Type', 'text/css')"> ---------------------------------------------- How can I have a ZPT act as my external stylesheet and set that response header? That is, how do I emulate the dtml-call above in a ZPT? Thanks, Shane McChesney http://www.skippingdot.net
On Sat, Jun 29, 2002 at 10:48:42AM -0400, Shane McChesney wrote:
I'm just learning Zope, and trying to stick to ZPTs over DTML wherever possible.
This may be one of the cases where it's not possible.
How can I have a ZPT act as my external stylesheet and set that response header? That is, how do I emulate the dtml-call above in a ZPT?
I *think* ZPT is only useful when you have valid XML content, which style sheets are not (or I'm doing them wrong, one or the other). In my case, I just made the external style sheet a DTML method, with nothing but the stylesheet content itself. No setheader commands or anything. It's worked so far, but might not be the absolute best solution. -- Mike Renfro / R&D Engineer, Center for Manufacturing Research, 931 372-3601 / Tennessee Technological University -- renfro@tntech.edu
Howdy,
In my case, I just made the external style sheet a DTML method, with nothing but the stylesheet content itself. No setheader commands or anything. It's worked so far, but might not be the absolute best solution.
I do similar, but put my external style sheet content in DTML documents instead of methods (seems like the most 'generic' container for static HTML/CSS content...or should I use a File object instead?). I link them as in normal HTML, but the links are in ZPTs instead of DTML docs/methods, like: <head> ... <title tal:content="template/title">Title Of Page</title> ... <LINK REL=StyleSheet HREF="onestylesheet.css" TYPE="text/css"> ... </head> ... Haven't grasped the purpose to the setheader commands - what fancy stuff can one do with them? John S. __________________________________________________ Do You Yahoo!? Yahoo! - Official partner of 2002 FIFA World Cup http://fifaworldcup.yahoo.com
Shane McChesney wrote:
It talks about using the LINK tag to incorporate external CSS that is still an editable Zope object, exactly what I want, but it's a DTML object, and I'm not sure how to replicate this line in a ZPT:
From: http://www.zope.org/Members/mindlace/css_zope ---------------------------------------------- IMPORTANT: You must have the following line as the first line of your method:
<dtml-call "RESPONSE.setHeader('Content-Type', 'text/css')"> ----------------------------------------------
How can I have a ZPT act as my external stylesheet and set that response header? That is, how do I emulate the dtml-call above in a ZPT?
Unfortunately, ZPT works only with xml/html. You have to use DTML for cascading style sheets. ~mindlace
Unless your style sheet is dynamic, I would just use a file object. As of Zope 2.5, you can edit textual ones through the web or you can use FTP, DAV or external editor. Just set the content type property to "text/css". Then link to it the usual way in your standard template. File objects will automatically set the proper headers that all browsers/proxies to cache them. If you use DTML, you will need to set the headers yourself or use an HTTP cache manager, which I would highly recommend unless your CSS is browser specific, in which case that is not possible. If there are browser specific parts I might suggest the following: Put the non-browser specific parts in a file object. Then create a DTML method (or a Python script if you don't feel like using DTML) to generate the browser specific parts. Set a RAM cache manager up for this object keyed to the data that would make the CSS different, such as AUTHENTICATED_USER and/or HTTP_USER_AGENT. This will keep Zope from having to render the dynamic CSS on every request. Then setup your standard template to link to the CSS file object (which is static). Following that add a <style> tag that inlines the dynamic part right into each page. That way, the browser only has to make one request in most cases (since the static css will be cached). For large static pages, you could opt to link to the dynamic CSS rather than inline it so that the static content is cacheable. For dynamic (or small pages), the extra request will be more significant, so inline it instead. By placing the bulk of your CSS in a static file and the rest inline, your pages will render without so much "jumping" as well. If the browser has to download all the CSS everytime (because its non-cacheable), then many will render the page without CSS first and again once the CSS comes down. This makes for a rather jerky user experience. hth, -Casey ----- Original Message ----- From: "Shane McChesney" <shane@nooro.com> Newsgroups: gmane.comp.web.zope.general Sent: Saturday, June 29, 2002 10:48 AM Subject: External CSS via ZPTs I'd like to use a CSS stylesheet editable within the Zope Management Interface, and refer to it from a LINK tag in the HEAD of each page. I'm just learning Zope, and trying to stick to ZPTs over DTML wherever possible. I searched Zope.org, and found mindlace's post of a "CSS & Zope howto" in 1999. It talks about using the LINK tag to incorporate external CSS that is still an editable Zope object, exactly what I want, but it's a DTML object, and I'm not sure how to replicate this line in a ZPT: From: http://www.zope.org/Members/mindlace/css_zope ---------------------------------------------- IMPORTANT: You must have the following line as the first line of your method: <dtml-call "RESPONSE.setHeader('Content-Type', 'text/css')"> ---------------------------------------------- How can I have a ZPT act as my external stylesheet and set that response header? That is, how do I emulate the dtml-call above in a ZPT? Thanks, Shane McChesney http://www.skippingdot.net _______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
Hello Casey, Saturday, June 29, 2002, 11:40:37 PM, you wrote: CD> By placing the bulk of your CSS in a static file and the rest inline, your CD> pages will render without so much "jumping" as well. If the browser has to CD> download all the CSS everytime (because its non-cacheable), then many will CD> render the page without CSS first and again once the CSS comes down. This CD> makes for a rather jerky user experience. The "jumping" you're referring to , is caused by a bug in Ms Internet Explorer , and can be avoiding by having at least one set of <style></style> or <script></script> in the head of your document, with or without content in them. I usually just add an empty <script></script> , and the problem/quirk is gone forever. :-) -- Geir Bækholt web-developer geirh@funcom.com funcom oslo | webdev-team
Interesting. Although I was not referring to IE. Many browsers display the page w/o CSS first and after the CSS downloads, they apply it causing the page to be drawn twice. -Casey ----- Original Message ----- From: "Geir Bækholt" <geirh@funcom.com> To: "Casey Duncan on the zope-list" <casey@zope.com> Cc: <zope@zope.org> Sent: Sunday, June 30, 2002 1:27 AM Subject: Re: [Zope] Re: External CSS via ZPTs Hello Casey, Saturday, June 29, 2002, 11:40:37 PM, you wrote: CD> By placing the bulk of your CSS in a static file and the rest inline, your CD> pages will render without so much "jumping" as well. If the browser has to CD> download all the CSS everytime (because its non-cacheable), then many will CD> render the page without CSS first and again once the CSS comes down. This CD> makes for a rather jerky user experience. The "jumping" you're referring to , is caused by a bug in Ms Internet Explorer , and can be avoiding by having at least one set of <style></style> or <script></script> in the head of your document, with or without content in them. I usually just add an empty <script></script> , and the problem/quirk is gone forever. :-) -- Geir Bækholt web-developer geirh@funcom.com funcom oslo | webdev-team
participants (6)
-
Casey Duncan -
emf -
Geir Bækholt -
John Schinnerer -
Mike Renfro -
Shane McChesney