0

Can I use HTML content in a Static Box? If so, please provide the code that I can use in the Block Content to identify the code as HTML. I am trying to use a Widget to insert HTML content into the Main Content Container of a Category page to use as a landing page.

  • Please add your Magento version and explain your requirement here. – Sumit Nov 26 '19 at 5:13
  • Magento 2.3. I think the answer is probably no, but I am new to all of this and working on my own site with a template. I would think that I could add html within a static block - to render a similar page content, but I have been unsuccessful. However, I thought it was worth checking with. – user84557 Nov 26 '19 at 12:55
  • Thank you for the information. I've added the answer for the same. Please check. – Sumit Nov 27 '19 at 4:11
1

Magento Allows to use HTML content in Static block. Block can be create by Admin from Admin Panel or Programmatically.

I will show you how Admin can add HTML content in Static Block.

Step:1 Login into your Magento Admin Penal

Step:2 After Login Click on CONTENT-> Blocks

Going to Static Block Section

Step:3 After Click you will see the Block Grid then Click on Add New Block

enter image description here

Step:4 After you have to fill Block Details,the HTML Content and Widget are Add here

enter image description here

Step:5 After save your Block Are show here

enter image description here

Note: Every Static Block name have Unique Identifier name so please keep notice that

Now you want to Add you Static Block in Category page. so you have to Overwrite module-catalog file in your theme.

app/design/[venore_name] / [Theme_name] / Magento_catalog/layout

Add this file

catalog_category_view.xml

<?xml version="1.0"?>

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <referenceContainer name="content">
        <block class="Magento\Cms\Block\Block" name="static_block_identifier_name" >
            <arguments>
                <argument name="block_id" xsi:type="string">static_block_identifier_name</argument>
            </arguments>
        </block>
    </referenceContainer>
</page>

Add here your Static block identifier name shown in Above block Grid. you can also use after and before attribute of this block tag like

you can also need to add same code in catalogsearch_result_index.xml. at same Path

Note: you have used default.xml for the layout changes, which will add the layout update in all pages.

After Done above Process you need to run this command

php bin/magento s:up

php bin/magento s:s:d -f

php bin/magento c:c 

php bin/magento c:f 

After Clear your Browse cache by using ctrl+shift+delete and Refresh your Page.

I Hope This Helps You.

  • if you have any doubt you can ask here – Msquare Nov 27 '19 at 17:23
  • +1 for a Good explanation. – Sumit Dec 3 '19 at 4:29

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.