Question

I'm doing a website which has lots and lots of different documents. They need them that way because they want to do all kind of filters and so on.

Since it is a really big company with a lot of structure they have a really set in stone hierarchy of content.

That way only inside some folders they want some kind of content types.

The only successful way I made it work was creating a per-content type global addable folderish content type which only allows to create the needed content type inside it and nothing else.

So in their FTI definition I have (on the global addable folderish content type):

...
  <property name="allowed_content_types">
    <element value="the.only.desired.contenttype" />
  </property>
...

I used to see the "Restrict content types" on the "Add new..." dropdown, which would be extremely helpful in my case, since I have like 22 containers and 22 more content types, whereas with that "Restrict content types" I would only have 1 container and 22 content types.

Is there any way to do that on Dexterity?

Was it helpful?

Solution

Not a direct answer to your Dexterity question, but...

only inside some folders they want some kind of content types.

I've found folder-local permissions work beautifully for this.

  • You don't need any custom container types - just use regular Folders.
  • Ideally each item type needs its own add permission e.g. ACME: Add Thing 1 and ACME: Add Thing 2 for Thing 1 and Thing 2 types respectively.
  • Rather than set the roles who have the permission at the site root (i.e. in rolemap.xml), set them only on the Folder where they're required.

That's it. The rest of the setup of these content types is as normal. Make them globally addable. The permission assignment means they'll only really be addable in the specific folders you've chosen.

If you don't want the usual types (Page, Link, etc.) addable in that folder, turn off the acquiring of the relevant add permissions.

This is one case where it's ok to break the (very sensible) rule of using only workflow to manage permissions below the site root. Since it's easy to lose track of where you've been, I would set the local permissions in code in my setuphandlers.py so there's a clear record of which folders are affected.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top