i have a main page template: index_html i have a number of content templates that i would like to include into my main page. the title property is set for each object: content_1, title = "number one" content_2, title = "number two" content_3, title = "number three" i'm trying to dynamically choose which content object to display based on a request variable. here is what i have in index_html: <HTML tal:define="page request/page | string:content_1"> <span tal:replace="python:container[page].title">title</span> <span tal:replace="structure python:container[page]">body</span> this is what i see if i browse to index_html?page=content_2 number one <ZopePageTemplate instance at 8960bf0> so the title is working! but the body is not. how can i get zope to include the contents of the object? is there a better way to translate a string into an object? if i make a call to tal:replace="container/content_1" i have no problems - i just can't figure out how to do this dynamically... thanks!
On Tue, Apr 30, 2002 at 01:06:12PM -0700, Russell Uman wrote: | | i have a main page template: index_html | i have a number of content templates that i would like to include | into my main page. the title property is set for each object: | content_1, title = "number one" | content_2, title = "number two" | content_3, title = "number three" | | i'm trying to dynamically choose which content object to display | based on a request variable. | | here is what i have in index_html: | | <HTML tal:define="page request/page | string:content_1"> | <span tal:replace="python:container[page].title">title</span> | <span tal:replace="structure python:container[page]">body</span> | | this is what i see if i browse to index_html?page=content_2 | | number one | <ZopePageTemplate instance at 8960bf0> This is the repr() of the object. | so the title is working! but the body is not. It works, it's just not what you really meant to ask for :-). | how can i get zope to include the contents of the object? is there a | better way to translate a string into an object? if i make a | call to tal:replace="container/content_1" i have no problems - i | just can't figure out how to do this dynamically... <span tal:replace="structure python:container[page]()">body</span> ^^ ^^ I think it would be clearer if you made index_html a Python Script instead. It's what I'm doing with a site whose index needs to be dynamically created based on who the user is and the contents of some SQL dbs. # Script(Python) page REQUEST.get( 'page' , None ) : if not page : page = 'content_1' print container[page].title print container[page]() return printed HTH, -D -- Pride only breeds quarrels, but wisdom is found in those who take advice. Proverbs 13:10 GnuPG key : http://dman.ddts.net/~dman/public_key.gpg
participants (2)
-
dman -
Russell Uman