I'm making a few backend modifications to my Zope page so that different content styles can be selected. I'm trying to create a page-viewing mode which eliminates tables, graphics, JavaScript, etc. from my pages, and adds in a few extre navigation buttons. To help with this, I'm modifying my navigation bar system. Originally I wanted to create menu methods on each page which output the actual HTML of the links, but I'm changing this to a more abstract system. I've created a menuitems property on each folder which I'd like to have a sidebar attached to, and the standard_html_header loops through this. I'm running into a problem, though. The property in which I'm storing the menu data is formatted like: <relative ID of document being linked to> <title for menu item> . . . and the code basically loops through this and inserts the data into the anchor tags. (I plan to add sound to my page and would like to allow folks the option of turning it off site-wide, so even though this looks pointless, it makes sense. :) And the (very broken and silly :) snippet of code is: <dtml-in menuitems> <dtml-if sequence-even> <a href="<dtml-var "_['sequence-item'].absolute_url()">"> <dtml-else> <dtml-var sequence-item></a><br> </dtml-if> </dtml-in> So, of course, I'm calling absolute_url() on a string, when I'd like to be calling it on an object. The sequence-item is always an object ID when the index is even, so what I'd like is code which returns an object when passed its ID; something which assumes that the ID is either in the current folder, or is being acquired. So, something like: myResume = this().lookup("resume") would return an object and allow me to call myResume.absolute_url(). Is there such a beast? And, if not, how difficult would it be to write? Could this be done as a DTML method? Thanks a bunch.
----- Original Message ----- From: "Nolan Darilek" <nolan_d@bigfoot.com> To: <zope@zope.org> Sent: Friday, May 05, 2000 9:35 PM Subject: [Zope] Another Zope question
And the (very broken and silly :) snippet of code is: <dtml-in menuitems> <dtml-if sequence-even> <a href="<dtml-var "_['sequence-item'].absolute_url()">"> <dtml-else> <dtml-var sequence-item></a><br> </dtml-if> </dtml-in>
So, of course, I'm calling absolute_url() on a string, when I'd like to be calling it on an object. The sequence-item is always an object ID when the index is even, so what I'd like is code which returns an object when passed its ID; something which assumes that the ID is either in the current folder, or is being acquired. So, something like:
Actually, you're almost there... You use _['sequence-item'] to look up a variable called sequence-item in the namespace.... similarly, you can do _[_['sequence-item']] to look up sequence-item, and then look up that string in the namespace. So, _[_['sequence-item']].absolute_url() will give you the URL of that object. Kevin
"Kevin" == Kevin Dangoor <kid@kendermedia.com> writes:
Kevin> Actually, you're almost there... You use _['sequence-item'] Kevin> to look up a variable called sequence-item in the Kevin> namespace.... similarly, you can do _[_['sequence-item']] Kevin> to look up sequence-item, and then look up that string in Kevin> the namespace. So, _[_['sequence-item']].absolute_url() Kevin> will give you the URL of that object. Here is the modified code. <dtml-in menuitems> <dtml-if sequence-even> <a href="<dtml-var "_[_['sequence-item']].absolute_url()">"> <dtml-else> <dtml-var sequence-item></a><br> </dtml-if> </dtml-in> While this does get the object, it reports a SystemError. The page also takes nearly a minute to generate, and the hundreds of lines of traceback seem to repeat over and over, so I'm thinking that the code is somehow caught in a loop of some sort, though I don't understand how the extra _[] could have caused this. Thanks.
Kevin Dangoor wrote:
----- Original Message ----- From: "Nolan Darilek" <nolan_d@bigfoot.com> To: <zope@zope.org> Sent: Friday, May 05, 2000 9:35 PM Subject: [Zope] Another Zope question
And the (very broken and silly :) snippet of code is: <dtml-in menuitems> <dtml-if sequence-even> <a href="<dtml-var "_['sequence-item'].absolute_url()">"> <dtml-else> <dtml-var sequence-item></a><br> </dtml-if> </dtml-in>
So, of course, I'm calling absolute_url() on a string, when I'd like to be calling it on an object. The sequence-item is always an object ID when the index is even, so what I'd like is code which returns an object when passed its ID; something which assumes that the ID is either in the current folder, or is being acquired. So, something like:
I think you should use getitem, like so (untested): <a href="<dtml-var "_.getitem('sequence-item').absolute_url()">"> -- ethan mindlace fremen mindlace@imeme.net zope -&- imap email -&- mailing list weave your web with the web at http://imeme.net
participants (3)
-
Kevin Dangoor -
mindlace -
Nolan Darilek