FriendsOfTYPO3 / content-blocks

TYPO3 CMS Content Blocks - Content Types API
https://docs.typo3.org/p/friendsoftypo3/content-blocks/main/en-us/
GNU General Public License v2.0
64 stars 18 forks source link

Reuse RecordType in Collection and enforce type #101

Open nhovratov opened 10 months ago

nhovratov commented 10 months ago
-
  identifier: relations
  type: Collection
  foreign_table: tx_dsboilerplate_contentblockrelation
  shareAcrossTables: true
  shareAcrossFields: true
  overrideChildTca:
    columns:
      type:
        config:
          default: dsboilerplate_linktiles_test
          readOnly: true
  foreign_match_fields:
    type: dsboilerplate_linktiles_test
-
  identifier: relations2
  type: Collection
  foreign_table: tx_dsboilerplate_contentblockrelation
  shareAcrossTables: true
  shareAcrossFields: true
  overrideChildTca:
    columns:
      type:
        config:
          default: dsboilerplate_linktiles_test2
          readOnly: true
  foreign_match_fields:
    type: dsboilerplate_linktiles_test2

Screenshot 2024-01-26 at 21-41-13 Edit Page Content No title on page Home · Content Blocks TYPO3 CMS 12 4 10

nhovratov commented 10 months ago

Interesting use case came up in Slack. The user wanted to reuse a RecordType with 2 different variations. The type should be automatically set in context to the Content Block it is used in. This is possible, however it requires a lot of boilerplate code.

Option 1: Document this specific use case as a guide article. Option 2: Allow to use this logic with a shortcut and only document the easy way. E.g.: enforceType: typeA

nhovratov commented 10 months ago

For reference, I used the foreign_match_fields method from TCA: https://docs.typo3.org/m/typo3/reference-tca/main/en-us/ColumnsConfig/Type/Inline/Properties/ForeignMatchFields.html

nhovratov commented 4 months ago

todo: evaluate if we could provide type restrictions like in Mask: https://github.com/Gernott/mask/blob/main/Classes/ItemsProcFuncs/CTypeList.php

This is of course really hacky. Maybe this could be a Core feature instead?