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.

Sumit
5,0482 gold badges22 silver badges36 bronze badges
asked Nov 26, 2019 at 5:05
3
  • Please add your Magento version and explain your requirement here. Commented Nov 26, 2019 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. Commented Nov 26, 2019 at 12:55
  • Thank you for the information. I've added the answer for the same. Please check. Commented Nov 27, 2019 at 4:11

1 Answer 1

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.

answered Nov 27, 2019 at 17:21
1
  • if you have any doubt you can ask here Commented Nov 27, 2019 at 17:23

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.