Re: [Zope] standard_html_header difficulties
Darcy Clark <darcyc@engin.umich.edu> wrote:
What I want to do seems like it should be simple, but from my newbie/non-Zen/still-confused-by-acquisition perspective I am stumped.
I have a standard_html_header in / folder :
<HTML> <HEAD> <TITLE> <!--#var title_or_id--> </TITLE> </HEAD>
<BODY>
In the /mse250 folder, I have a method index_html with title="The MSE250 Homepage" as follows :
<!--#var standard_html_header-->
<H2><!--#var document_title--></H2>
blah, blah, blah ....
What I want to do is have my standard_html_header file use <!--#var document_title--> (i.e. "The MSE250 Homepage") instead of the root folder <!--#var title_or_id--> (i.e. MSE250) between the <TITLE> </TITLE> tags. This seems like a logical thing to want to do - to cut down on the amount of repetitive code by using a standard header, but at the same time, having the header change depending on what method is calling it.
DTML Documents and Methods have a property, document_title, which gives what you want. -- ========================================================= Tres Seaver tseaver@palladion.com 713-523-6582 Palladion Software http://www.palladion.com
Tres Seaver wrote:
Darcy Clark <darcyc@engin.umich.edu> wrote:
What I want to do seems like it should be simple, but from my newbie/non-Zen/still-confused-by-acquisition perspective I am stumped.
I have a standard_html_header in / folder :
<HTML> <HEAD> <TITLE> <!--#var title_or_id--> </TITLE> </HEAD>
<BODY>
In the /mse250 folder, I have a method index_html with title="The MSE250 Homepage" as follows :
<!--#var standard_html_header-->
<H2><!--#var document_title--></H2>
blah, blah, blah ....
What I want to do is have my standard_html_header file use <!--#var document_title--> (i.e. "The MSE250 Homepage") instead of the root folder <!--#var title_or_id--> (i.e. MSE250) between the <TITLE> </TITLE> tags. This seems like a logical thing to want to do - to cut down on the amount of repetitive code by using a standard header, but at the same time, having the header change depending on what method is calling it.
DTML Documents and Methods have a property, document_title, which gives what you want.
unfortunately I don't think this works....if the standard_html_header is 'inserted' into my mse250/index_html with the statement "<!--#var document_title-->", it unfortunately doesn't 'acquire' the document_title of the mse250/index_html method, but rather uses it's own document_title (in my case "standard_html_header"). As I said earlier, it seems to be something that should be necessary for a great many websites - i.e. to have isolate the header for re-use through the site, but have it access/acquire the properties of the method that 'calls' it .... I cannot believe that this is not possible with Zope. Darcy
========================================================= Tres Seaver tseaver@palladion.com 713-523-6582 Palladion Software http://www.palladion.com
-- --------------------------------------------------- Ph: (734) 764 3377 Email: darcyc@engin.umich.edu URL: http://www-personal.engin.umich.edu/~darcyc/ --------------------------------------------------- 'If you're not part of the solution, you're part of the precipitate' ..... Steven Wright
This is working here. In folder DEMO DTML-method standard_head with <HTML> <HEAD> <TITLE><!--#var title_or_id--></TITLE> </HEAD> <BODY BGCOLOR="#FFFFFF"> Folder MYFOLDER DTML-Document index_html (title -> 'a simple start') with <!--#var standard_header--> <h2><!--#var title_or_id--></h2> <p> This is the <!--#var id--> Document. <dtml-var document_title> </p> <!--#var standard_html_footer--> This renders to: (Sorry I have no public site) <HTML><HEAD><TITLE>a simple start</TITLE></HEAD><BODY BGCOLOR="#FFFFFF"> <h2>a simple start</h2> <p> This is the index_html Document. a simple start </p> <p><a href="http://www.zope.org/Credits"> <img src="http://lisboa.ifm.uni-kiel.de:9080/p_/ZopeButton" width="115" height="50" border="0" alt="Powered by Zope"></a> </p> </BODY></HTML> Is this what you want? Important is the difference between DTML-Method and DTML-Document __Janko
Janko, thanks for explaining this....it works for me also. Although I must admit that I am still suprised that I cannot get this to work somehow if index_html is a method. The reason I am trying to use methods is that in my standard_html_header I am also using the <!--#tree--> tag - this tag only seems to work properly if index_html is a method. I guess I still don't appreciate the finer points of methods/documents and acquisition. cheers, Darcy Janko Hauser wrote:
This is working here.
In folder DEMO
DTML-method standard_head with <HTML> <HEAD> <TITLE><!--#var title_or_id--></TITLE> </HEAD> <BODY BGCOLOR="#FFFFFF">
Folder MYFOLDER
DTML-Document index_html (title -> 'a simple start') with <!--#var standard_header--> <h2><!--#var title_or_id--></h2> <p> This is the <!--#var id--> Document. <dtml-var document_title> </p> <!--#var standard_html_footer-->
This renders to: (Sorry I have no public site)
<HTML><HEAD><TITLE>a simple start</TITLE></HEAD><BODY BGCOLOR="#FFFFFF">
<h2>a simple start</h2> <p> This is the index_html Document. a simple start </p> <p><a href="http://www.zope.org/Credits"> <img src="http://lisboa.ifm.uni-kiel.de:9080/p_/ZopeButton" width="115" height="50" border="0" alt="Powered by Zope"></a> </p> </BODY></HTML>
Is this what you want? Important is the difference between DTML-Method and DTML-Document
__Janko
-- --------------------------------------------------- Ph: (734) 764 3377 Email: darcyc@engin.umich.edu URL: http://www-personal.engin.umich.edu/~darcyc/ --------------------------------------------------- 'If you're not part of the solution, you're part of the precipitate' ..... Steven Wright
Darcy Clark wrote:
Janko,
thanks for explaining this....it works for me also. Although I must admit that I am still suprised that I cannot get this to work somehow if index_html is a method.
Think of methods as a pseudopod of a folder, not a entity unto itself. They're best used for DTML code that has at least folder-wide scope, in my experience. I try to push as much presentation logic into methods as I can, and use DTML documents as content objects.
The reason I am trying to use methods is that in my standard_html_header I am also using the <!--#tree--> tag - this tag only seems to work properly if index_html is a method. I guess I still don't appreciate the finer points of methods/documents and acquisition.
<dtml-tree expr="PARENTS[0]"> will make a tree starting from the folder above the DTML Document. <dtml-if "meta_type == 'DTML Document> <dtml-tree expr="PARENTS[0]"></dtml-tree> <dtml-else "meta_type == 'DTML Method'> <dtml-tree expr="PARENTS[1]"></dtml-tree> </dtml-if> might be what you're looking for. Feel free to add branch_expr etc. -- Ethan "mindlace" Fremen you cannot abdicate responsibility for your ideology.
Ethan, thanks for the mail. Methods and documents are becoming clearer...but at the same time I keep finding that I almost want to be able to switch modes within the same page. So for some parts of a page/layout (whatever you want to call it), I want it to act as a 'pseudopod of a folder', and then later on, (for instance to get standard_html_header to work like I want) I want the same page/layout to work in the document 'mode'. Manipulating namespaces and contexts is currently not a trivial matter which I am frankly finding very confusing (yet powerful at the same time). cheers, Darcy Ethan Fremen wrote:
Darcy Clark wrote:
Janko,
thanks for explaining this....it works for me also. Although I must admit that I am still suprised that I cannot get this to work somehow if index_html is a method.
Think of methods as a pseudopod of a folder, not a entity unto itself. They're best used for DTML code that has at least folder-wide scope, in my experience. I try to push as much presentation logic into methods as I can, and use DTML documents as content objects.
The reason I am trying to use methods is that in my standard_html_header I am also using the <!--#tree--> tag - this tag only seems to work properly if index_html is a method. I guess I still don't appreciate the finer points of methods/documents and acquisition.
<dtml-tree expr="PARENTS[0]">
will make a tree starting from the folder above the DTML Document.
<dtml-if "meta_type == 'DTML Document> <dtml-tree expr="PARENTS[0]"></dtml-tree> <dtml-else "meta_type == 'DTML Method'> <dtml-tree expr="PARENTS[1]"></dtml-tree> </dtml-if>
might be what you're looking for. Feel free to add branch_expr etc.
-- Ethan "mindlace" Fremen you cannot abdicate responsibility for your ideology.
-- --------------------------------------------------- Ph: (734) 764 3377 Email: darcyc@engin.umich.edu URL: http://www-personal.engin.umich.edu/~darcyc/ --------------------------------------------------- 'If you're not part of the solution, you're part of the precipitate' ..... Steven Wright
participants (4)
-
Darcy Clark -
Ethan Fremen -
Janko Hauser -
Tres Seaver