[Plone-UI] Page template needs gif used to be conditional of the current path
veda at onenw.org
Wed Sep 3 17:15:50 UTC 2008
That's funny, I was just going to blog about this. Here's a little snippet
or two that might help:
<!-- this snippet looks up to the root and finds an image there called
<img src="" id="section-top"
alt="Background image" />
<!-- this snippet looks in your current context and finds an image called
section-top.jpg; if there's nothing there, it displays nothing and doesn't
error out -->
<img src="" tal:define="img nocall:context/section-top.jpg"
We use nocall because you have to do that if you give a path expression to a
real object (as opposed to a method on an object, which is more normal), or
else zope will publish it and you'll get the rendered HTML for the page for
viewing that object, which is quite ugly.
In this particular case, at the root of your site you'd add a fallback image
named section-top.jpg, and elsewhere in the site you can add different
images. If there isn't a section-top.jpg in a given section, it'll default
to the one at the root. They both should be named the same, btw.
This doesn't suit your use case, but is an interesting approach I use quite
On 9/3/08 6:02 AM, "treid" <anthonyfreid at gmail.com> wrote:
> I have a viewlet page template called portal_bottom.pt that calls gif for
> I would like the gif used to be conditional of the current path.
> So if the URL starts with "domain.com/special-path" I would like the image
> to be displayed "image-b.gif" otherwise I would like the image to be
> img src="/path/to/graphic/image-" if URL starts with "/special-path" "b.gif"
> else "a.gif" ...
> I'm guessing a little python is needed here but I don't know python so could
> someone help me out please?
More information about the UI