How to get rid of header and footer information?
Hi, I ran into the following problem with Zope: If you create a Zope document you will probably include something like <dtml-var standard_whatever_header> and <dtml-var standard_whatever_footer> into the main text area, thereby giving layout information for the default rendering of the item. Problem is, when you try to access the main content of the document, say, for non-default purposes like a text-only version or inclusion into some digest, you always get this default layout information too - if you want it or not. So I have two related questions: 1. Is it possible to reference the main content area of a document EXCLUDING the header and footer information, just like a 'clean' property field? 2. Is there a better way than including Headers and Footers, maybe by relating a document somehow with different separate 'template'-like dtml-methods for default and non-standard ways of rendering the document? Sorry, if this is a stupid newbie question, and thanks in advance, Lorenz. ________________________________________________________ Dr. Lorenz Lorenz-Meyer Holstenring 2 22763 Hamburg E-Mail: lorenz@clubvolt.de Tel: +49 40 5259 5551 AIM: lorenzlm Mobil: +49 179 139 5819 ________________________________________________________
On Fri, May 31, 2002 at 05:26:40PM +0200, Lorenz Lorenz-Meyer wrote:
1. Is it possible to reference the main content area of a document EXCLUDING the header and footer information, just like a 'clean' property field?
Perhaps you can take some cues from zope.org. Look at http://www.zope.org/standard_html_header/view_source and http://www.zope.org/standard_html_footer/view_source and pay particular attention to lines that refer to 'pp' (printable page) in the DTML. Clicking the Printable Page link at the bottom of the pages re-renders that page without the side navigation and such. FYI, you can use that view_source method all over the zope.org site. Very helpful. -Tim -- Tim Wilson | Visit Sibley online: | Check out: Henry Sibley HS | http://www.isd197.org | http://www.zope.com W. St. Paul, MN | | http://slashdot.org wilson@visi.com | <dtml-var pithy_quote> | http://linux.com
Thanks, Tim, this was helpful: Tim Wilson <wilson@visi.com> schrieb:
Perhaps you can take some cues from zope.org. Look at http://www.zope.org/standard_html_header/view_source and http://www.zope.org/standard_html_footer/view_source and pay particular attention to lines that refer to 'pp' (printable page) in the DTML.
But it is in my opinion no good solution for the more general problem of a clear-cut separation of structured content on the one hand and layout information on the other. I would still very much like to learn a way to have the main text area treated like a normal field - with associated dtml-methods providing for the looks of the content on different page-types. Take, for example, a situation where you want the complete content of a document included in some kind of list. How would you do that? Probably by handing over some parameter like "noheader" that is tested by the header method (<dtml-unless noheader>....). I think this is illogical. It should be the other way round somehow. Best regards, Lorenz. ________________________________________________________ Dr. Lorenz Lorenz-Meyer Holstenring 2 22763 Hamburg E-Mail: lorenz@clubvolt.de Tel: +49 40 5259 5551 AIM: lorenzlm Mobil: +49 179 139 5819 ________________________________________________________
Bonjour, --- Lorenz Lorenz-Meyer <lorenz@clubvolt.de> wrote:
But it is in my opinion no good solution for the more general problem of a clear-cut separation of structured content on the one hand and layout information on the other. I would still very much like to learn a way to have the main text area treated like a normal field - with associated dtml-methods providing for the looks of the content on different page-types.
I suspect that you can do what you are asking using ZPT - as I understand it ZPT is (are?) explicitly designed to support the separation you are asking for (if I understand what you're asking for...).
Take, for example, a situation where you want the complete content of a document included in some kind of list. How would you do that? Probably by handing over some parameter like "noheader" that is tested by the header method (<dtml-unless noheader>....). I think this is illogical. It should be the other way round somehow.
For this case, I think you can make a ZPT 'shell' that iterates (with tal:repeat) through whatever page body ZPTs you want in the list and inserts each one into the rendered page via macro. With ZPT macro stuff (METAL), your page layout 'shell' template, header, footer, and body/content (and whatever other parts you want) are separated. You can render a page body without header/footer simply by calling a different 'shell' template that doesn't include header and footer macros. Or you can do it with a TAL condition statement that includes (or not) header/footer macros (or whatever) depending on context. For my printable pages I simply have a 'printerpages' folder with an alternate style sheet (same name, different styles) in it. To render somefolder/somewhere/coolpage with printer page style, I call somefolder/somewhere/printerpages/coolpage, so that the printable page style sheet is found first. In some instances I combine this with conditions based on context, for example to use a grayscale logo instead of color on printable pages, like this: <!-- use color logo if not in printerpages --> <span tal:condition="python:request.PARENTS[0].id!='printerpages'"> <img src="graphics/pageshelllogo.gif" alt="Home" width="95" height="56" border="0"> </span> <!-- use grayscale logo if in printerpages --> <span tal:condition="python:request.PARENTS[0].id=='printerpages'"> <img src="graphics/pageshelllogogray.gif" alt="Home" width="95" height="56" border="0"> </span> cheers, John S. __________________________________________________ Do You Yahoo!? Yahoo! - Official partner of 2002 FIFA World Cup http://fifaworldcup.yahoo.com
Here is how I'm doing it with ZPT (don't know if it's the best solution but it works very well): I have an 'index_html' Page Template at the top of my site. It only contains this: <div metal:use-macro="container/template_standard/macros/page">Ma Page</div> I also have a 'template_standard' Page Template containing my macros: <div metal:define-macro="page" .....> <html> <head> <link .... this_is_a_link_to_a_complex_stylesheet> </head> <body> <My Complex Header Here> <div tal:replace="structure python:here.get_content(here, request)">Retrieving the page content.</div> </body> </html> </div> The 'get_content' Python Script retrieves the content. It needs 2 parameters (client, mapping) from Products.PythonScripts.standard import structured_text content_html = context.content_html(client, mapping) if hasattr(context, 'stx'): if context.stx: content_html = structured_text(context.content_html(client, mapping)) return content_html If I want a printable page, I add a 'print' Page template' which contains only this: <div tal:use-macro="container/template_print/macros/page">Printable Page</div> And, of course, I have a 'template_print' Page Template with a more simple header and a link to a simple stylesheet. With that structure, if I want to add a page, I add a Folder with a 'content_html' object into it. This object could be a Page Template or a DTML Method. And if the folder have a 'stx' properties (evaluated to true of course), you can add your content in structured text. So a page is just a Folder with a content_html into it. -- Olivier Laurent. P3B : Club Python(-Zope) Belge --------- http://www.p3b.org OS3B : Club Open-Software(-Linux) Carolo http://www.os3b.org Aragne : Python-Zope Solutions & Formations http://www.aragne.com
participants (4)
-
John Schinnerer -
Lorenz Lorenz-Meyer -
Olivier Laurent -
Tim Wilson