[Zope] Including DTML in an HREF Link?

Thomas B. Passin tpassin@mitretek.org
Fri, 19 Apr 2002 10:57:13 -0400


[Dan Shafer]

> What, if any, syntax permits me to put a dtml-call construct inside a
> hyperlink on a Web page?
>
> Right now, it seems to me that to execute a dtml-call, I have to create a
> DTML document which makes that call and then invoke the DTML document in
> the usual way in the link tag. This results in a bit of extra effort and
> extra files but I don't mind doing this if that's the most effective or
> efficient way.
>
> Conceptually, what I want (with the initial angle bracket removed to avoid
> formatting issues) is:
>
> a href="<dtml-call someDTMLMethodName>">link text </a>
>
> Now, I know that particular syntax won't work, but it shows what I believe
> I want.
>
> Or am I doing it the "best practices way"?
>
>

You can get right to an object by traversal.  For example, suppose you have
a folder called "test", and a method in that folder called "theMethod".  You
can invoke it with this url:

http://yourserver/test/theMethod

You can use that in a link.  If you include a query string, the method can
access the request:

http://yourserver/test/theMethod?xxx=yyy

In the method,

<dtml-var "REQUEST.xxx">

will render "yyy".

Remember, though, if you do this you should really have the method return a
complete html page with all the trimmings.  In that case, there's not
necessarily a big advantage in using a method rather than a document.

Cheers,

Tom P