3

I'm trying to make an addon both Plone 4 and Plone 5 compatible. The problem I'm running into is the profiles/default XML.

Plone 5: I have a registry.xml for registering CSS Plone 4: I have a cssregistry.xml for registering CSS

I was hoping Plone 4 would ignore the registry.xml but it picked it up and then crashes during the install in Plone 4. Is there a solution to this?

hietpasd
  • 455
  • 2
  • 10

2 Answers2

6

You can have multiple profiles pointing to different profile directories (they are defined in configure.zcml), and the Plone docs have examples of how to conditionally evaluate ZCML:

<include zcml:condition="have plone-4" package=".package" />
<include zcml:condition="not-have plone-4" package=".otherpackage" />

There's also a straight "evaluate content if condition is met" by having zcml:condition on a configure.

Community
  • 1
  • 1
Ulrich Schwarz
  • 7,598
  • 1
  • 36
  • 48
  • 2
    I commonly not use separate subpackages, but you can use the same approach for registering an alternative profiles. Example: https://github.com/RedTurtle/TurtledGazette/blob/94fa38cc0b877a30cd8aec592aeea1ef553cb8a3/Products/PloneGazette/profiles.zcml#L16 – keul Oct 21 '15 at 06:17
  • Is there a similar condition for plone 5 then? that would be safer – Danimal Oct 21 '15 at 10:03
  • @Danimal: [plone.app.mosaic](https://github.com/plone/plone.app.mosaic/blob/master/src/plone/app/mosaic/browser/configure.zcml) seems to use `have plone-5`, but I have no Plone 5 here to double-check. – Ulrich Schwarz Oct 21 '15 at 10:40
  • 2
    Watch out: 'have plone-4' will be true on both Plone 4 and Plone 5. See https://github.com/plone/Products.CMFPlone/blob/5.0/Products/CMFPlone/meta.zcml#L13. So you should use 'have plone-5' and 'not-have plone-5'. – maurits Oct 22 '15 at 19:37
0

What you said works great when you add:

xmlns:zcml="http://namespaces.zope.org/zcml"

To the top configuration. Just a note for any future people who need this.

hietpasd
  • 455
  • 2
  • 10