0

I'm trying to modify my /portal_view_customizations/zope.interface.interface-plone.belowcontenttitle.documentbyline template with a tal expression, so that the document's author and the modification date do not show if the current portal type is a Document (Page). I don't mind if it shows for News Items, which are time sensitive, but not the Documents/Pages.

This is my failing Plone TAL expression:

<div class="documentByLine"
     id="plone-document-byline"
     i18n:domain="plone"
     tal:condition="view/show and not:python:here.portal_type == 'Document'"> 
...

I've also tried:

<div class="documentByLine"
     id="plone-document-byline"
     i18n:domain="plone"
     tal:condition="view/show and not:context/portal_type='Document'">

but still no luck. The tracebacks are pretty cryptic and don't relate to the TAL expression. However, if I get rid of my condition for portal_type, then it works again. Any thoughts are appreciated. A manual would be good, but I've looked at the official ones, and they don't mention this.

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
elmor
  • 310
  • 1
  • 17
  • Might it have something to do with my 'and' clause? I see from http://plone.293351.n2.nabble.com/Plone-Users-if-else-statements-in-TAL-td312142.html that my second attempt is very close. – elmor Mar 24 '14 at 20:03

1 Answers1

2

TAL's underlying TALES, the expression-engine of which TAL makes use of, doesn't support the mixing of expression-types in one expression. It's syntax allows only one expression-type to be specified (defaults to 'path', if omitted, btw), as no delimiter is provided (like a semicolon for chaining several TAL-statements in one element, e.g.).

But instead of mixing three expression-types you can use one python-expression, try:

python: view.show and context.portal_type()!='Document'

Update:

If you have customized a Plone's default-template via portal_view_customizations ('TTW'), now restricted python-methods cannot be accessed, that' why view/show throws an error.

It returns the allowAnonymousViewAbout-property of the site-properties, you can also check this condition yourself and your expression looks like:

tal:define="name user/getUserName" 
tal:condition="python:test(name!='Anonymous User') and context.portal_type()!='Document';

Quick'n'dirty alternative:

Do it with CSS:

body.userrole-anonymous .documentByLine {display:none}
body:not(.template-document_view) .documentByLine {display:block}

This will render the hidden elements, but it's helpful for prototyping and such, or 'quickfixes' (no admin available, etc.).

Ida
  • 3,994
  • 21
  • 40
  • thank you, I had gotten this working before I read your answer, but yours is much more compact. Thank you!`code`
    ...`code`
    – elmor Mar 24 '14 at 22:47
  • After trying yours, it's erring with the familiar "AttributeError: 'TTWViewletRenderer' object has no attribute '__name__'". So maybe yours would work if I had it in a view, not TTW? – elmor Mar 24 '14 at 22:55