[Zope] if-tag question
Oleg Broytmann
Oleg Broytmann <phd@phd.pp.ru>
Thu, 29 Nov 2001 15:16:04 +0300
On Thu, Nov 29, 2001 at 12:10:13PM +0000, Stephan Goeldi wrote:
> I have this dtml-if tag:
>
> <dtml-if expr="REQUEST.PATH_TRANSLATED == '/folder1/subfolder1'">
>
> This is true, if I am in /folder1/subfolder1
>
> it is not true, when I am in /folder1/subfolder1/object1
>
> When I want, that /folder1/subfolder1/object1 is true too, I have to ask
> something like if ... CONTAINS /subfolder1. How can I do that with the
> dtml-if tag?
<dtml-if "REQUEST.PATH_TRANSLATED[:_.len('/folder1/subfolder1')] == '/folder1/subfolder1'">
More recent Python has .startswith:
<dtml-if "REQUEST.PATH_TRANSLATED.startswith('/folder1/subfolder1')">
(but I am not sure if REQUEST.PATH_TRANSLATED is a string; if not -
convert it to a string: _.str(REQUEST.PATH_TRANSLATED))
Oleg.
--
Oleg Broytmann http://phd.pp.ru/ phd@phd.pp.ru
Programmers don't die, they just GOSUB without RETURN.