[Zope] Reusing standard_html_header/footer

Michael Gutmann gutmann@uni-duesseldorf.de
Thu, 6 Jul 2000 11:31:58 +0200


This is not a question, I think it's more a request for comment.

Problem: I have the following structure of folders. The top folder has
the global standard_html_header and acquisition has it, that it
is usable in all the subfolders. 

/
  standard_html_header
  SubFolder1/
     SubFolder2/

Now I have a small modification in my headers from SubFolder1 downwards.
Well, there are many ways to cope with that problem, I want to do it 
that ways: I want to integrate the old standard_html_header into the
new one I define in SubFolder1. Ok, that can look like this:

<load old standard_html_header>
<my addtional code>

The problem I have to solve now, is to load the old standard_html_header.

Solution: I will give you all my tries, just for fun :-))

:-(	First try:	<dtml-var standard_html_header>
	The easy way certainly doesn't work. It gives a nice error:
	"SystemError: infinite recursion in document template"
	And it shows you, that Zope really is quick. It does the 
	infinite loop in less than 30 seconds :-)))

:-(	Second try:	<dtml-var "PARENTS[1].standard_html_header">
	Well, this gives me the right object, but it isn't rendered. As
	I reviewed the list archive, I found out, that this seems to be
	normal. Maybe somebody can explain why, if he/she has 
	some sparetime.

:-(	Third try:	<dtml-var "PARENTS[1].standard_html_header(_.None,_)">
	Wow, it works! But, as the smiley implies, it has its disadvantages:
	Using it in SubFolder2 gives again an infinite recursion.
	Find out for yourselves, why ;-))

:-)	Fourth try:	<dtml-var "PARENTS[-1].standard_html_header(_.None,_)">
		or:	<dtml-var "FolderName.standard_html_header(_.None,_)">
			if you want to use the method of a subfolder.
	That seems to be the right way. Any comments?

After the second try (my first serious one ;-) I tried the following:

<dtml-with "PARENTS[-1]">
   <dtml-var standard_html_header>
</dtml-with>

but this has the disadvantage, that standard_html_header uses the namespace
of PARENTS[-1] to display things like id or title.

Maybe this should go into the FAQ?

Happy zoping,
Michael

=======================================================================
Michael Gutmann M.A.                    | 
Universitaetsrechenzentrum              | 
Heinrich-Heine-Universitaet Duesseldorf	| 
Tel.  : +49 211 81-11969                |        
e-mail: gutmann@uni-duesseldorf.de      | This space is intentionally
http://gutmann.rz.uni-duesseldorf.de/   | left blank.
=======================================================================