Search code examples
crafter-cms

Not able to use content inheritance in Crafter CMS


Following this documentation, I was trying to implement content inheritance but I could not.

My simple use case is:

Parent component contains CSS data. Child component inherits from it and populates its template with CSS links.

In documentation:

Child: Below is the XML file of a page residing under the above level descriptor and is setup to inherit from it. You’ll note the definition of the merge-strategy as inherit-levels, this invokes the level-based inheritance mechanics that require Crafter CMS to look at current and higher levels for files named crafter-level-descriptor.level.xml (this is configurable). You’ll also note that this page doesn’t specify the CSS file/group of files to include, nor will it need to specify the header nor footer components.

In child page's config.xml file there is no reference of parent.

My question are?

  1. Where to create crafter-level-descriptor.level.xml using studio?
  2. page residing under the above level descriptor what does this mean, what kind of levels?

Note: I am new to crafter-cms and sometimes the documentation is confusing.


Solution

  • Parent and child here refer to instances of the content, not the content type definition.

    Levels refer to folders in a hierarchy.

    crafter-level-descriptor.level.xml is a file created on a folder or subfolder, and items (XML files) that have the inherit-levels inheritance strategy defined will inherit from the level descriptor crafter-level-descriptor.level.xml adjacent to the item (same folder level) and higher levels (parent folders) all the way to the root folder.

    For common concerns that you'd like a section (folder hierarchy) to inherit, specify that at a parent level, and have the children (pages or components with that inheritance strategy), defined to have 'inherit-levels' strategy and those metadata fields will automatically show up in the child items, even if not defined in their model.