Migration guide - CmsBlockWidget

Edit on GitHub

Upgrading from Version 1.* to Version 2.*

In the CmsBlockWidget module version 2.0.0, we have:

  • updated `CmsBlockWidgetTwigPlugin` with the support of getting CMS blocks by keys and names;
    
  • increased the version of `spryker/cms-block-storage` in `composer.json`;
    
  • removed the `TwigCmsBlock` plugin;
    
  • introduced `CmsBlockWidgetToCmsBlockStorageClient::findBlocksByKeys()` that finds blocks by keys;
    
  • introduced `CmsBlockWidgetToCmsBlockStorageClient::findBlockKeysByOptions()` that finds block keys by provided options;
    
  • deprecated `CmsBlockWidgetToCmsBlockStorageClient::findBlocksByNames()`;
    
  • removed `CmsBlockWidgetToCmsBlockStorageClient::findBlockNamesByOptions()`;
    
  • removed `CmsBlockWidgetToCmsBlockStorageClient::generateBlockNameKey()`.
    

Upgrade to the new version of the module:

  1. Upgrade the CmsBlock module to version 3.0.0. See Migration Guide - CmsBlock.
  2. Upgrade the CmsBlockStorage module to version 2.0.0. See Migration Guide - CmsBlockStorage.
  3. Upgrade the CmsBlockWidget module to version 2.0.0:
composer require spryker-shop/cms-block-widget:"^2.0.0" --update-with-dependencies

The new version of the CmsBlockWidget module implements the spyCmsBlock widget that gets data by CMS block keys.You can still use the widget that gets data by CMS block names, e.g. {{ spyCmsBlock(name: 'Block name') }}. However, this will cause two separate storage requests to be created in the back end. The first gets mapped keys by CMS block names while the second uses those keys to get CMS blocks. Also, if a widget has both key and name parameters, the key parameter is processed first.

Use the new widget:

  1. with the key parameter:
{{ spyCmsBlock(keys: ['blck-1']) }}
  1. with the name parameter (deprecated functionality):
{{ spyCmsBlock(name: 'Block name') }}
  1. with the category and position parameters:
{{ spyCmsBlock({ category: category_id, position: 'top' }) }}
  1. with the product parameter:
{{ spyCmsBlock({ product: product_id }) }}

Estimated migration time: 30m-1h