TAL: getting container of template
Hi, although the TAELS Overview in the Zope help states that the built in name container refers to "The folder in which the template is located", obviously the container of the object the tamplate is applied to is returned. But I would like to get the parent or container of the actual template to build a independent navigational structure. As I know where the template resides this would be very helpful (my users access the site in question aas host.domain.com, But I am working and testing it as anotherhost.domain.com:8080/Folder I am trying to build a navigation that fits both). I tried to get to URLPATHn or other veriables off the request object as described in the docu thrugh the tal-name "request" but to no avail is this something different or do I need to use some sort of accessor on these??? Thanks for any help on the way to ZopeZEN ;-) Jochen
Jochen Haeberle wrote:
although the TAELS Overview in the Zope help states that the built in name container refers to "The folder in which the template is located", obviously the container of the object the tamplate is applied to is returned.
"Obviously"? (scribbles some quick test code...) Nope, it's the template container, as documented.
I tried to get to URLPATHn or other veriables off the request object as described in the docu thrugh the tal-name "request" but to no avail is this something different or do I need to use some sort of accessor on these???
It should work fine like this: <span tal:replace="request/URLPATH1">The path</span> Cheers, Evan @ 4-am
At 16:48 Uhr -0500 02.09.2002, Evan Simpson wrote:
Jochen Haeberle wrote:
although the TAELS Overview in the Zope help states that the built in name container refers to "The folder in which the template is located", obviously the container of the object the tamplate is applied to is returned.
"Obviously"? (scribbles some quick test code...) Nope, it's the template container, as documented.
I would not like to argue with you on this ;-) But how do you test for this??? <span tal:replace="container">test</span> gives <Folder Instance at###> <span tal:replace="container/absolute_url">test</span> gives the url to the object the template is applied to... What should I do to get a vh-enabled url to the container of my template???
I tried to get to URLPATHn or other veriables off the request object as described in the docu thrugh the tal-name "request" but to no avail is this something different or do I need to use some sort of accessor on these???
It should work fine like this:
<span tal:replace="request/URLPATH1">The path</span>
Mhmm.. don't know, how I spoiled that one... sorry ;-)
Cheers,
Evan @ 4-am
Thanks for shedding some light... Jochen
Jochen Haeberle wrote:
I would not like to argue with you on this ;-) But how do you test for this???
I put a test ZPT into a 'scratch' Folder with <span tal:replace="container/id">ID</span> and visited it using several URLs leading through various paths and pieces of content. It always says "scratch".
<span tal:replace="container/absolute_url">test</span> gives the url to the object the template is applied to...
Are there ZClasses, Products, or other complications involved here, or are we just talking about objects in Folders?
Mhmm.. don't know, how I spoiled that one... sorry ;-)
S'Okay, Evan @ 4-am
Jochen Haeberle wrote:
I would not like to argue with you on this ;-) But how do you test for this???
I put a test ZPT into a 'scratch' Folder with <span tal:replace="container/id">ID</span> and visited it using several URLs leading through various paths and pieces of content. It always says "scratch".
<span tal:replace="container/absolute_url">test</span> gives the url to the object the template is applied to...
Are there ZClasses, Products, or other complications involved here, or are we just talking about objects in Folders?
no, just folders and (rbickers Photo) objects. My template lives in the root folder of my site and there are Photo Folders spanning one to three levels deep. By using container/absolute_url I hoped to always get the url of my root-folder to build a navigation, independent of using vh or not. Jochen
Hi Evan, using container/id, it still shows another folder as expected, but I guess I know what's going on... container returns the folder the "main" template is in, not the template the code itself is in, probably due to inside-out macro expansion. So that behaviour is okay, but still no way to go for a navigation :-( Jochen At 17:53 Uhr -0500 02.09.2002, Evan Simpson wrote:
Jochen Haeberle wrote:
I would not like to argue with you on this ;-) But how do you test for this???
I put a test ZPT into a 'scratch' Folder with <span tal:replace="container/id">ID</span> and visited it using several URLs leading through various paths and pieces of content. It always says "scratch".
<span tal:replace="container/absolute_url">test</span> gives the url to the object the template is applied to...
Are there ZClasses, Products, or other complications involved here, or are we just talking about objects in Folders?
On Mon, Sep 02, 2002 at 10:16:49PM +0200, Jochen Haeberle wrote:
But I would like to get the parent or container of the actual template to build a independent navigational structure. As I know where the template resides this would be very helpful (my users access the site in question aas host.domain.com, But I am working and testing it as anotherhost.domain.com:8080/Folder I am trying to build a navigation that fits both).
The setup I've documented at http://www.zope.org/Members/mwr/ somewhat fits your description -- I've just verified that it does work if I use the normal virtual host namespace, or the literal hostname:portnumber/folder/ namespace. The first howto (python_zpt_sitemap) is my current setup, though I have some emails from folks on things to be changed. The second howto (python_zpt_sitemap_zen) has much better Python code, but I've not yet finished the ZPT for that version. My suggestion for a quick fix would be to use the second howto's code, change the last lines to return a list of objects instead of a dictionary, and then use the ZPT from the first howto. -- Mike Renfro / R&D Engineer, Center for Manufacturing Research, 931 372-3601 / Tennessee Technological University -- renfro@tntech.edu
Hi Mike, thanks for your note and the excelent HowTo. Although the overall scenario does not fit me, it was very interesting. the solution to my problem was your script getSiteRoot. Using this, I am now able to build my navigational-links based on my logical root :-) I did have some problems though, that I do not yet understand... when I use <a href = "#" tal:attributes="href string:${here/getSiteRoot/absolute_url}/Photos/"> it will put "/getSiteRoot/Photo" in the URL. If I put a tal:define="vhroot here/getSiteRoot" in front and query vhroot for absolute_url it works. Why is that??? Thanks anyway Jochen At 9:17 Uhr -0500 03.09.2002, Mike Renfro wrote:
On Mon, Sep 02, 2002 at 10:16:49PM +0200, Jochen Haeberle wrote:
The setup I've documented at http://www.zope.org/Members/mwr/ somewhat fits your description -- I've just verified that it does work if I use the normal virtual host namespace, or the literal hostname:portnumber/folder/ namespace. -- Mike Renfro / R&D Engineer, Center for Manufacturing Research, 931 372-3601 / Tennessee Technological University -- renfro@tntech.edu
participants (3)
-
Evan Simpson -
Jochen Haeberle -
Mike Renfro