I have created a module to add a secondary CMS block to category pages, and everything is working fine in the back-end and I select whichever CMS I want. However, nothing appears on the front-end of the site when I have selected one.

I presume it's something to do with my catalog_product_view.xml as that's where my default CMS block is; I'm just unsure of what to actually write in here.

My Secondary CMS Module is below:


<?xml version="1.0" encoding="UTF-8"?>
<form xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
<fieldset name="content">
    <field name="landing_page_secondary">
        <argument name="data" xsi:type="array">
            <item name="options" xsi:type="object">Magento\Catalog\Model\Category\Attribute\Source\Page</item>
            <item name="config" xsi:type="array">
                <item name="sortOrder" xsi:type="number">65</item>
                <item name="dataType" xsi:type="string">string</item>
                <item name="formElement" xsi:type="string">select</item>
                <item name="label" xsi:type="string" translate="true">Add Secondary CMS Block</item>


namespace Juicy\CategoryCMS\Setup;

use Magento\Eav\Setup\EavSetup;
use Magento\Eav\Setup\EavSetupFactory;
use Magento\Framework\Setup\InstallDataInterface;
use Magento\Framework\Setup\ModuleContextInterface;
use Magento\Framework\Setup\ModuleDataSetupInterface;

class InstallData implements InstallDataInterface
    private $eavSetupFactory;

     * Init
     * @param EavSetupFactory $eavSetupFactory
    public function __construct(EavSetupFactory $eavSetupFactory)
        $this->eavSetupFactory = $eavSetupFactory;

     * {@inheritdoc}
     * @SuppressWarnings(PHPMD.ExcessiveMethodLength)

    public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
        /** @var EavSetup $eavSetup */
        $eavSetup = $this->eavSetupFactory->create(['setup' => $setup]);

         * Add attributes to the eav/attribute - landing_page_secondary

            'landing_page_secondary', [
                'type' => 'int',
                'label' => 'Secondary CMS Block',
                'input' => 'select',
                'source' => 'Magento\Catalog\Model\Category\Attribute\Source\Page',
                'required' => false,
                'sort_order' => 25,
                'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE,
                'group' => 'Display Settings',


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.