enonic / xp

Enonic XP
https://enonic.com
GNU General Public License v3.0
202 stars 34 forks source link

Support content type filter in x-data schema #6215

Closed alansemenov closed 6 years ago

alansemenov commented 6 years ago

As an application developer, For a specific x-data, I want to be able to specify a filter for content types that shall be able to use it. I want to be able to either explicitly specify content types to allow or use a regex to allow content types based on a specific pattern (see https://github.com/enonic/xp/issues/6154).

Use the mixin only on the landing-page content type :

<?xml version="1.0" encoding="UTF-8"?>
<x-data>
  <display-name>Menu</display-name>
  <allowContentType>landing-page</allowContentType>
  <items>
...
  </items>
</x-data>

Use the x-data on the landing-page content type and any content type from a specific app containing media substring:

<?xml version="1.0" encoding="UTF-8"?>
<x-data>
  <display-name>Menu</display-name>
  <allowContentType>landing-page</allowContentType>
  <allowContentType>^app.enonic.com.features:media*</allowContentType>
  <items>
...
  </items>
</x-data>

Use the mixin on all content types but only from the current app:

<?xml version="1.0" encoding="UTF-8"?>
<x-data>
  <display-name>Menu</display-name>
  <allowContentType>^{$app}:*</allowContentType>
  <items>
...
  </items>
</x-data>

Allow all content types except for the ones containing htmlarea substring:

<?xml version="1.0" encoding="UTF-8"?>
<x-data>
  <display-name>Menu</display-name>
  <allowContentType>((?!htmlarea).)*$</allowContentType>
  <items>
...
  </items>
</x-data>

Conditions of satisfaction:

sigdestad commented 6 years ago

I'm just curious if it would be better to call it contentTypeFilter instead of allowContentType? Maybe filter is too unclear?