Add Collection with collective.collectionfilter portlets from add-on profile

Would it be possible to install ( profiles/default and / or setuphandlers.py)

  1. Collective.collectionfilter
  2. Make a Collection, set criterias
  3. "Lock" view (display) for everybody, also admins
  4. Enable different 'Collectionfilter' portlets on the collection.

1 and maybe 2 is pretty straightforwars (metadata.xml and types.xml)

About 3, I assume it should be possible to change 'Change View Template' permissions, or do I (really) have to make a new workflow for this ?

About 4: I have no idea how this could work, where is this info saved?

Strangely enough the Collection critereas are not saved in 'content export' either:

cd path/to/setuptoolexport/structure/mycollection 
vi .data 

query:
sort_on:
sort_reversed: False
limit: 1000
item_count: 30
customViewFields: Title||Creator||Type||ModificationDate
allow_discussion:
id: my-id
exclude_from_nav: False
title: My Collection
description:
subjects:
language: en-us
effective:
expires:
creators: admin
contributors:
rights:
relatedItems:
Portal-Type: Collection

about 3, you can just configure the type to have only 1 display view.

For 4. you can use genericsetup: provide a XML file portlets.xml in your profile folder which looks like this:

<?xml version="1.0" encoding="utf-8"?>
<portlets>

  <!-- Assign a context portlets -->
  <assignment category="context"
              key="/path/to/your/collection"
              manager="plone.leftcolumn"
              name="my-portlet"
              type="portlets.Navigation"
  />
...
</portlets>

This probably has to run after setuphandlers, but is possible if it is put in another profile and run from there (for example having 'profile-beforedefault in metadate)

 <dependency>my-addon:beforedefault</dependency> 

My main confusion is how to add the critereas to the portlet.

This is for 'Collection', so cant do that.

This is the code, that imports <property /> nodes inside the <assignment /> node https://github.com/plone/plone.app.portlets/blob/master/plone/app/portlets/exportimport/portlets.py#L161 ... the following (untested!) snipped should set the values to the collectionfilter portlet:

<assignment category="context"
              key="/path/to/your/collection"
              manager="plone.leftcolumn"
              name="my-portlet"
              type="collective.collectionfilter.portlets.CollectionFilter">
    <property name="title">My Filter portlet</property>
    <property name="group_by">Subject</property>
    <property name="show_count">True</property>
</assignment>

Note: you do not need to set the target_collection if your portlet context is the collection anyways.

Thanks, works great (except from the title which seems to be 'header' in this case.

  <!-- Assign a collection filter portlet -->
  <assignment category="context"
          key="/path/to/collection"
          manager="plone.rightcolumn"
          name="collectionfilterone"
          type="collective.collectionfilter.portlets.CollectionFilter">
    <property name="header">My Header</property>
    <property name="group_by">Subject</property>
    <property name="show_count">True</property>
 </assignment>

Of course :thinking: :laughing: