Since Plone 6 moved a lot of settings from Products.CMFPlone to plone.base, the registry settings between Plone 5 and 6 are differ a bit. I'm showing you how to register settings for both major Plone versions.
To archive this, we need to separate the registry settings from our default profile. We instead use a profile for Plone 5 and 6 each which different registry settings..
post_install hook method
The following configure.zcml entries define a default profile and our two new profiles for plone5 or plone6. The profiles have the same name, but only one is actually registered at a time, depending on the zcml:condition="have plone-5" or zcml:condition="have plone-6".
<genericsetup:registerProfile
name="default"
directory="profiles/default"
title="collective.resourcebooking"
description="Installs the collective.resourcebooking add-on."
provides="Products.GenericSetup.interfaces.EXTENSION"
post_handler=".setuphandlers.post_install"
/>
<genericsetup:registerProfile
name="z-conditionals"
directory="profiles/plone5"
title="collective.resourcebooking"
description="Installs the collective.resourcebooking add-on."
provides="Products.GenericSetup.interfaces.EXTENSION"
zcml:condition="have plone-5"
/>
<genericsetup:registerProfile
name="z-conditionals"
directory="profiles/plone6"
title="collective.resourcebooking"
description="Installs the collective.resourcebooking add-on."
provides="Products.GenericSetup.interfaces.EXTENSION"
zcml:condition="have plone-6"
/>
Note
make sure that your configure.zcml file has xmlns:zcml="http://namespaces.zope.org/zcml" defined in the configure tag.
The default profile is loaded by default, but our z-conditionals profiles are not. We have to load them our self. To do this, we use the post_install hook of the default profile and load the "z-conditionals" profile via Python code.
In our setuphandlers.py we should have the following code:
def post_install(context):
"""Post install script"""
# Do something at the end of the installation of this package.
loadMigrationProfile(
context,
"profile-collective.resourcebooking:z-conditionals",
)
With this configuration in place, we need to add two new sub folders ('plone5', 'plone6') in our profiles folder. In these folders we create a registry folder where our registry files live.
Now let's fill the profiles with registry settings.
In the plone5 folder we want to set settings for the Navigation like this:
<?xml version='1.0' encoding='UTF-8'?>
<registry>
<records interface="Products.CMFPlone.interfaces.controlpanel.INavigationSchema" prefix="plone">
<value key="displayed_types" purge="false">
<element>ResourceBooking</element>
<element>Resources</element>
<element>Bookings</element>
</value>
</records>
</registry>
for Plone 6 on the other hand, we want to set it like this:
<?xml version='1.0' encoding='UTF-8'?>
<registry>
<records interface="plone.base.interfaces.controlpanel.INavigationSchema" prefix="plone">
<value key="displayed_types" purge="false">
<element>ResourceBooking</element>
<element>Resources</element>
<element>Bookings</element>
</value>
</records>
</registry>
Alternative approach
Another way to load additional profiles would be, to depend on them in the default profile. But it is not as robust in my opinion.
In your configure.zcml you can register your profiles like this:
<genericsetup:registerProfile
name="install-base"
title="collective.resourcebooking BASE"
directory="profiles/base"
description="Installs the collective.resourcebooking add-on."
provides="Products.GenericSetup.interfaces.EXTENSION"
post_handler=".setuphandlers.post_install"
/>
<genericsetup:registerProfile
description="Installs the collective.resourcebooking add-on."
directory="profiles/plone5"
name="default"
provides="Products.GenericSetup.interfaces.EXTENSION"
title="collective.resourcebooking"
zcml:condition="have plone-5"
/>
<genericsetup:registerProfile
description="Installs the collective.resourcebooking add-on."
directory="profiles/plone6"
name="default"
provides="Products.GenericSetup.interfaces.EXTENSION"
title="collective.resourcebooking"
zcml:condition="have plone-6"
/>
Note
make sure that your configure.zcml file has xmlns:zcml="http://namespaces.zope.org/zcml" defined in the configure tag.
The default profile folder we rename to base.
In our plone5/plone6 folders we add a metadata.xml with a dependency to the install-base profile.
<?xml version="1.0"?>
<metadata>
<dependencies>
<dependency>profile-collective.resourcebooking:install-base</dependency>
</dependencies>
</metadata>