简体   繁体   中英

Changing attributes in Zope templates

I'm writing a template for an object that contains files. I'm following the theme building blocks instructions .

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

That makes that the liks downloads the file, as this:

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

But I want that link points to the view page of the file, showing its title, description and also, allowing to download it. So I want to get the next output:

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

How can I generate that attribute?

Use a string: expression adding the /view part:

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

Note that you probably want to use the .absolute_url() (for objects) or the .getURL() (for catalog results) methods instead to generate full absolute URLs for your items:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM