How set/configure the view conditional?

I have registered an alternate view "Excelfile to Datatables" for IFile.
Is it possible to set/configure the action for select default view in the "Display Menu" conditional, based on the mimetype of the file? What i mean is, the action "selectViewTemplate" should only available, if the file has a certain mimetype.

<!-- configure.zcml snippet -->
<!-- alternative fileview, Excel to Datatables-->
  title="Excel to Datatables"
  expression="..???.." />

I think you can't. A portal_actions action supports conditions.

I am pretty sure some add-on did this. Maybe it was collective.documentviewer.

Actually, I think used some of this code in GitHub - espenmn/medialog.issuu: goal is to include issuu in plone (but I made it 10 years ago, so hard to remember).

Maybe check this line: medialog.issuu/actions.xml at master · espenmn/medialog.issuu · GitHub

Update: And maybe: medialog.issuu/ at master · espenmn/medialog.issuu · GitHub

This was not the question.
It is obvious that you can do everything on the Python layer but not on the declarative ZCML layer.

I know that is no problem via actions.xml, like @zopyx says, i want a solution via browser:page directive. But I thought so, that it was not possible.

The "proper" way to do it is to have an IExcel(IFile) interface and set it on supported objects only.
Using only IExcel would probably work too.

You can set this marker interfaces (fairly) easily in an event handler - both on add and on modify - where you can check the file's mime type.

1 Like

@jaroel thanks for hint

Plone Foundation Code of Conduct