Changing Attributes in Zope Templates

I am writing a template for an object that contains files. I am following the instructions.

<a tal:attributes="href item/id">foo</a>

      

This means that likes is downloading the file, since this:

<a href="foo">foo</a>

      

But I want this link to point to the view page of the file, displaying its name, description, and also allowing it to be downloaded. So I want to get the following output:

<a href="foo/view">foo</a>

      

How can I generate this attribute?

+3


source to share


1 answer


Use an expression string:

adding a part /view

:

<a tal:attributes="href string:${item/id}/view">foo</a>

      



Note that you probably want to use methods .absolute_url()

(for objects) or .getURL()

(for catalog results) to generate full absolute URLs for your items:

<a tal:attributes="href string:${item/absolute_url}/view">foo</a>

      

+5


source







All Articles