SwissUpLabs Logo

Display activity and material blocks on product page

Activity and material blocks can be added to the product page with Inline php code, Layout update xml or Cms widget interface. Follow the description mentioned below to learn how to use each of the proposed ways.

Table of Contents

Screenshot

activity and material blocks on product page

Inline php code

You can add the code mentioned below to any template, that is shown on product page.

Look at list of available attributepages/product helper methods

<?php
    echo $this->helper('Swissup\Attributepages\Helper\Product')
        ->setProduct($block->getProduct())
        ->setAttributeCode([
            'activity',
            'material'
        ])
        ->setImageType('thumbnail')
        ->setCssClass('list-block')
        ->setParentPageLinkTitle([
            'activity'  => 'View All',
            'material' => 'View All'
        ])
        ->setUseImage([
            'activity'  => true,
            'material' => false
        ])
        ->setUseLink([
            'activity'  => true,
            'material' => true
        ])
        ->setSize(38, 17)
        ->setKeepFrame(false)
        ->toHtml();
?>

Layout update xml

Look at list of available product_option block methods

<referenceContainer name="product.info.extrahint">
    <block class="Swissup\Attributepages\Block\Product\Option" template="Swissup_Attributepages::product/options.phtml" name="attributepage_activity_material">
        <arguments>
            <argument name="attributeCode" xsi:type="string">activity,material</argument>
            <argument name="useImage" xsi:type="boolean">true</argument>
            <argument name="imageType" xsi:type="string">thumbnail</argument>
            <argument name="width" xsi:type="number">45</argument>
            <argument name="height" xsi:type="number">15</argument>
            <argument name="useLink" xsi:type="boolean">true</argument>
            <argument name="cssClass" xsi:type="string">hidden-label</argument>
        </arguments>
    </block>
</referenceContainer>

Cms widget interface

Widget popup

You can add this widget to the product page at Content > Elements > Widgets page with following layout update instructions:

Layout update instructions

Edit this Page