Automatically including another document
Here's what I'm trying to do: in a subdirectory off the current one, called "book", there is a file with the same name as this one, and I want to include it in the current DTML document. Here's what I have so far: <dtml-with book> <dtml-let text="_['URL'].split('/')[-1]"> <dtml-if text> <dtml-var text> </dtml-if> </dtml-let> </dtml-with> The problem is, <dtml-var text> simply spits out the name of the document, rather than the document contents. (I feel like I've struggled with this before...). Is it possible? 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:
Here's what I'm trying to do: in a subdirectory off the current one, called "book", there is a file with the same name as this one, and I want to include it in the current DTML document. Here's what I have so far:
<dtml-with book> <dtml-let text="_['URL'].split('/')[-1]"> <dtml-if text> <dtml-var text> </dtml-if> </dtml-let> </dtml-with>
The problem is, <dtml-var text> simply spits out the name of the document, rather than the document contents.
(I feel like I've struggled with this before...).
Is it possible?
Try this (assuming it's in a DTML document, otherwise get "thisid" in your workarond manner as per the last message): <dtml-let thisid="getId()"> <dtml-with book> <dtml-var "_[thisid]"> </dtml-with> </dtml-let> -- Chris McDonough Zope Corporation http://www.zope.org http://www.zope.com "Killing hundreds of birds with thousands of stones"
Works well. Now, can I test for existence of the included document? The following produces an "excessive recursion" error: <dtml-let thisid="getId()"> <dtml-with book> <dtml-if "_[thisid]"> <dtml-var "_[thisid]"> </dtml-if> </dtml-with> </dtml-let> *********** REPLY SEPARATOR *********** On 12/20/01 at 6:53 PM Chris McDonough wrote:
Bruce Eckel wrote:
Here's what I'm trying to do: in a subdirectory off the current one, called "book", there is a file with the same name as this one, and I want to include it in the current DTML document. Here's what I have so far:
<dtml-with book> <dtml-let text="_['URL'].split('/')[-1]"> <dtml-if text> <dtml-var text> </dtml-if> </dtml-let> </dtml-with>
The problem is, <dtml-var text> simply spits out the name of the document, rather than the document contents.
(I feel like I've struggled with this before...).
Is it possible?
Try this (assuming it's in a DTML document, otherwise get "thisid" in your workarond manner as per the last message):
<dtml-let thisid="getId()"> <dtml-with book> <dtml-var "_[thisid]"> </dtml-with> </dtml-let> -- Chris McDonough Zope Corporation http://www.zope.org http://www.zope.com "Killing hundreds of birds with thousands of stones"
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 ===================
Here's what I'm trying to do: in a subdirectory off the current one, called "book", there is a file with the same name as this one, and I want to include it in the current DTML document. Here's what I have so far:
<dtml-with book> <dtml-let text="_['URL'].split('/')[-1]"> <dtml-if text> <dtml-var text> </dtml-if> </dtml-let> </dtml-with>
You could do something like: <dtml-with book> <dtml-let "text=getId()"> <dtml-var "_.getitem(text,1)"> </dtml-let> </dmtl-with> seb
Here's what I'm trying to do: in a subdirectory off the current one, called "book", there is a file with the same name as this one, and I want to include it in the current DTML document. Here's what I have so far:
<dtml-with book> <dtml-let text="_['URL'].split('/')[-1]"> <dtml-if text> <dtml-var text> </dtml-if> </dtml-let> </dtml-with>
You could do something like: <dtml-with book> <dtml-let "text=getId()"> <dtml-var "_.getitem(text,1)"> </dtml-let> </dmtl-with> seb
participants (3)
-
Bruce Eckel -
Chris McDonough -
Seb Bacon