Skip to main content

How to display labels within manual position

There 2 types of placeholders that can be configured in the extension: positioned and manual. In most cases positioned placeholders manages to display labels automatically.

note

If for some reason positioned labels are not displayed in the storefront check the how to display labels within custom theme.

Labels with manual position allows you to display labels at almost any place near product card. The only thing that required is to put the following code in the template file wherever the labels should be displayed.

example
<?php
echo $block->getLayout()->createBlock('\Mirasvit\CatalogLabel\Block\Product\Label\Placeholder')
->setProduct($_product)
->setPlaceholderByCode(placeholder_code)
->setType(view_type)
->toHtml();
?>

where:

  • view_type: should be list or view correspondingly to where this code is placed.
  • placeholder_code: the identifier of the manually positioned placeholder.
  • $_product: contains a current product object.