Data model inheritance
Compose complex data structured through inheritance
Last updated
Compose complex data structured through inheritance
Last updated
Data model inheritance - often simplified to just "inheritance" - is a feature in Pokko that allows you to compose complex data models by basing one model off another, inheriting the properties from that other model.
Example: Website
You may be using Pokko to manage content for a website. This website consists of various kinds of pages - blog posts, portfolio items, media libraries, etc.
Being part of a website they all share some common properties - i.e., page titles, URLs, meta descriptions
Instead of creating a data model in Pokko for each page and adding these properties to each model, you could make use of inheritance and create a base model including all these common properties that your page types would inherit from.
Data model inheritance is best implemented when creating your models rather than retrospectively. You can move fields around once they have been created, but if any content has been created against the models you are reconfiguring it may be lost.
Following the above example, you would start by creating the Page model.
Field
Configuration
Title
Single line text, automatic source "Entry name"
URL slug
Single line text, automatic source "Entry name" with "slugify" transformation
Meta description
Single line text
When creating the Blog post and Portfolio item models, under the Inheritance section, click "Add" and choose "Page" from the dropdown.
With that configured, you will see in the Blog post model the fields that have been inherited from Page.