Categories: How ToMagento 2

How to Add Custom Extension File in Magento 2 CMS page

Working on Magento 2 custom development, you always need to pass through adding custom features and functionalities that default Magento missed. We, Magento developers of MageComp are there to enhance your E-commerce store functionality to the next level with our coding skills and customization.

A few days ago, while creating one CMS page, we came across the unique requirement of adding custom extension files to Magento CMS page for providing more options or functionality to our customers. The easiest solution is to create one CMS page and call the .phtml file in content page by creating a block using these steps.

Go to Content> Pages> Add New Page to create a new CMS page. Once the page is created, paste below code in the CMS page editor.

<pre class="lang:default decode:true">
{{block class="Vendor\Extension\Block\Index\Index" template="Vendor_Extension::index/index.phtml"}}
</pre>

Now under the hood of design tab, you need to embed CSS & JavaScript file using the head tag under Layout XML block.

<pre class="lang:default decode:true">
<head>
     <css src="Vendor_Extension/css/extension.css"/>
     <link src="Vendor_Extension/js/extension.js"/>
</head>
</pre>

Lastly, hit the save page button to save the configuration and changes will start appearing in the front-end.

So, smash down yellow stars if this worked for you & comment down below if you are looking for help regarding this solution.

Until that, Happy Coding.

Click to rate this post!
[Total: 6 Average: 4.3]
Dhiren Vasoya

Dhiren Vasoya is a Director and Co-founder at MageComp, Passionate 🎖️ Certified Magento Developer👨‍💻. He has more than 9 years of experience in Magento Development and completed 850+ projects to solve the most important E-commerce challenges. He is fond❤️ of coding and if he is not busy developing then you can find him at the cricket ground, hitting boundaries.🏏

Recent Posts

Magento 2: Add Quantity Increment and Decrement on Category Page

Hello Magento Friends, In this blog, we will discuss about adding quantity increment and decrement…

2 days ago

How to Integrate ChatGPT with Laravel Application?

In this guide, we'll explore how to integrate ChatGPT, an AI-powered chatbot, with a Laravel…

5 days ago

What are Net Sales? How to Calculate Your Net Sales?

In the world of business, understanding financial metrics is crucial for making informed decisions and…

1 week ago

Magento 2 Extensions Digest April 2024 (New Release & Updates)

Welcome to the MageComp Monthly Digest, where we bring you the latest updates, releases, and…

1 week ago

The ABCs of Geofencing: Definition, Features and Uses

In this era, businesses are always on the lookout for ways to engage with their…

1 week ago

How to Delete Product Variant in a Shopify Remix App using GraphQL Mutations?

Managing a Shopify store efficiently involves keeping your product catalog organized. This includes removing outdated…

1 week ago