The name of the current DTML-document
Is this a good way to get the name of the current DTML document? <dtml-var "_['URL'].split('/')[-1]"> Also, how would I print out all the fields for '_'? (always looking for a way to write code to figure out what I want to do...) Most current information can be found at: http://www.mindview.net/Etc/notes.html =================== Bruce Eckel http://www.BruceEckel.com Contains free electronic books: "Thinking in Java 2e" & "Thinking in C++ 2e" Please subscribe to my free newsletter -- just send any email to: join-eckel-oo-programming@earth.lyris.net My schedule can be found at: http://www.mindview.net/Calendar ===================
Bruce Eckel wrote:
Is this a good way to get the name of the current DTML document? <dtml-var "_['URL'].split('/')[-1]">
If you mean DTML Document, a better way is: <dtml-var getId> If you mean DMTL Method, a better way that usually works is: <dtml-var "this().getId()">
Also, how would I print out all the fields for '_'? (always looking for a way to write code to figure out what I want to do...)
No generally easy way because of the nature of _ (it's a "multimapping" that can have indeterminate number of stacked mappings, and it doesn't have an items, keys, or values method).. if anybody has ideas, please pipe up. ;-) -- Chris McDonough Zope Corporation http://www.zope.org http://www.zope.com "Killing hundreds of birds with thousands of stones"
If you mean DMTL Method, a better way that usually works is:
<dtml-var "this().getId()">
I lied. This is unreliable. At least it doesn't work for me. ;-) Your way is a reasonable workaround. -- Chris McDonough Zope Corporation http://www.zope.org http://www.zope.com "Killing hundreds of birds with thousands of stones"
<dtml-var document_id> works for both DTML Methods and DTML Documents. Chris McDonough wrote:
If you mean DMTL Method, a better way that usually works is:
<dtml-var "this().getId()">
I lied. This is unreliable. At least it doesn't work for me. ;-) Your way is a reasonable workaround.
-- Jim Washington
Yes, so the current leader for elegant solution (which works, I tried it) is: <dtml-with book> <dtml-if "_[document_id]"> <dtml-var "_[document_id]"> </dtml-if> </dtml-with> Cool! Thanks! *********** REPLY SEPARATOR *********** On 12/20/01 at 7:23 PM Jim Washington wrote:
<dtml-var document_id> works for both DTML Methods and DTML Documents.
Chris McDonough wrote:
If you mean DMTL Method, a better way that usually works is:
<dtml-var "this().getId()">
I lied. This is unreliable. At least it doesn't work for me. ;-) Your way is a reasonable workaround.
-- Jim Washington
Most current information can be found at: http://www.mindview.net/Etc/notes.html =================== Bruce Eckel http://www.BruceEckel.com Contains free electronic books: "Thinking in Java 2e" & "Thinking in C++ 2e" Please subscribe to my free newsletter -- just send any email to: join-eckel-oo-programming@earth.lyris.net My schedule can be found at: http://www.mindview.net/Calendar ===================
I take it back. The <dtml-if > doesn't work. It works only if the file exists under 'book'. <dtml-with book> <dtml-if "_[document_id]"> <dtml-var "_[document_id]"> </dtml-if> </dtml-with> So I'm still trying to figure out how to do the conditional... *********** REPLY SEPARATOR *********** On 12/20/01 at 7:23 PM Jim Washington wrote:
<dtml-var document_id> works for both DTML Methods and DTML Documents.
Chris McDonough wrote:
If you mean DMTL Method, a better way that usually works is:
<dtml-var "this().getId()">
I lied. This is unreliable. At least it doesn't work for me. ;-) Your way is a reasonable workaround.
-- Jim Washington
Most current information can be found at: http://www.mindview.net/Etc/notes.html =================== Bruce Eckel http://www.BruceEckel.com Contains free electronic books: "Thinking in Java 2e" & "Thinking in C++ 2e" Please subscribe to my free newsletter -- just send any email to: join-eckel-oo-programming@earth.lyris.net My schedule can be found at: http://www.mindview.net/Calendar ===================
Hi, Bruce Maybe this is what you want: <dtml-if "document_id in book.objectIds()"> <dtml-var "book[document_id]"> </dtml-if> -- Jim Washington Bruce Eckel wrote:
I take it back. The <dtml-if > doesn't work. It works only if the file exists under 'book'.
<dtml-with book> <dtml-if "_[document_id]"> <dtml-var "_[document_id]"> </dtml-if> </dtml-with>
So I'm still trying to figure out how to do the conditional...
That's it -- seems to work great. Thanks! *********** REPLY SEPARATOR *********** On 12/20/01 at 8:19 PM Jim Washington wrote:
Hi, Bruce
Maybe this is what you want:
<dtml-if "document_id in book.objectIds()"> <dtml-var "book[document_id]"> </dtml-if>
-- Jim Washington
Bruce Eckel wrote:
I take it back. The <dtml-if > doesn't work. It works only if the file exists under 'book'.
<dtml-with book> <dtml-if "_[document_id]"> <dtml-var "_[document_id]"> </dtml-if> </dtml-with>
So I'm still trying to figure out how to do the conditional...
Most current information can be found at: http://www.mindview.net/Etc/notes.html =================== Bruce Eckel http://www.BruceEckel.com Contains free electronic books: "Thinking in Java 2e" & "Thinking in C++ 2e" Please subscribe to my free newsletter -- just send any email to: join-eckel-oo-programming@earth.lyris.net My schedule can be found at: http://www.mindview.net/Calendar ===================
This is useful as well: http://www.zopelabs.com/cookbook/1001104105 Jim Washington wrote:
Hi, Bruce
Maybe this is what you want:
<dtml-if "document_id in book.objectIds()"> <dtml-var "book[document_id]"> </dtml-if>
-- Jim Washington
Bruce Eckel wrote:
I take it back. The <dtml-if > doesn't work. It works only if the file exists under 'book'.
<dtml-with book> <dtml-if "_[document_id]"> <dtml-var "_[document_id]"> </dtml-if> </dtml-with>
So I'm still trying to figure out how to do the conditional...
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
-- Chris McDonough Zope Corporation http://www.zope.org http://www.zope.com "Killing hundreds of birds with thousands of stones"
participants (3)
-
Bruce Eckel -
Chris McDonough -
Jim Washington