Story Block Engine
The information below needs vetting.
The Story Block Engine provide an editor interface for selecting a story and customizing the data for the story. The base story block - pmc/story provides universal post types on PMC themes.
When a post type should exist in its own block, for example a "Musician" block for Rolling Stone, the Story Block Engine can be used to create a new block, "Musician Story Card" like so:
- Scaffold a new block with
npm scaffold- Name it
Story Musician - Supply a slug. The slug will be the name slugified, eg.
story-musicianby default. - Supply an optional description.
- Select a category. Default
widget. - Select or search for a dashicon. Default
smiley. - Supply optional keywords, a comma-separated list. Default none.
- Defined whether or not the block should support
InnerBlocks. Defaultfalse.
- Name it
- Update it's block class to extend
Story_Block_Engine - Reference existing
src/blocks/(brand|feature)/class-story-X.phpfiles for setting configuration. - Look in src/blocks/(brand|feature)/story-musician/
- Reference existing story-influencers.js for setting the default postType attribute, and using
getStoryBlockRegistrationObjectto override default values when registering the new story block.
Adding a Post Type to pmc/story
The base pmc/story block should provide the universal PMC post types, for example, post, pmc_top_video, pmc_gallery and lists. To add a new post type to the story block, add a new array entry to the configuration in in class-story.php where the object key and the postType values are equivalent to $post->post_type, and the taxonomySlug is the taxonomy that should be displayed on the front end.
Filtering Configuration
Themes can filter configuration for story blocks. The filter names are created dynamically based on the block name, as can be seen in the localize_data method in Story_Block_Engine.
For example, a theme might not want to include pmc_top_video in the post type selection for the main story block. The theme can provide a filter called pmc_gutenberg_story_block_config that removes the entry with key pmc_top_story and returns the remaining configuration.