Story Block Engine

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:

  1. Scaffold a new block with npm scaffold
    1. Name it Story Musician
    2. Supply a slug. The slug will be the name slugified, eg. story-musician by default.
    3. Supply an optional description.
    4. Select a category. Default widget.
    5. Select or search for a dashicon. Default smiley.
    6. Supply optional keywords, a comma-separated list. Default none.
    7. Defined whether or not the block should support InnerBlocks. Default false.
  2. Update it's block class to extend Story_Block_Engine
  3. Reference existing src/blocks/(brand|feature)/class-story-X.php files for setting configuration.
  4. Look in src/blocks/(brand|feature)/story-musician/
  5. Reference existing story-influencers.js for setting the default postType attribute, and using getStoryBlockRegistrationObject to 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.