Magento 2: How to Add Custom Action Button at CMS Page Backend 

Magento 2 How to Add Custom Action Button at CMS Page Backend

Hello Magento Friends,

With the amount of customization that Magento 2 has to offer, it gives developers the capabilities to expand admin panel functionalities to their own specifications. One such customization could be adding a custom action button on the backend edit screen for the CMS page, whether that means activating a custom module, exporting data, or navigating to another page, a custom button on your CMS page edit screen can help the admin panel workflow significantly.

Magento version upgrade

In this blog, we are going to show you how to add a custom action button on the CMS page edit screen in Magento 2 admin.

Steps to Add Custom Action Button at CMS Page Backend in Magento 2:

Step 1: First, we need to create a “cms_page_form.xml“ file inside our extension at the following path

app\code\Vendor\Extension\view\adminhtml\ui_component\cms_page_form.xml

Then add the code as follows

<?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">
    <argument name="data" xsi:type="array">
        <item name="buttons" xsi:type="array">
            <item name="check_on_page" xsi:type="string">Vendor\Extension\Block\Adminhtml\AddButton\CheckButton</item>
        </item>
    </argument>
</form>

Step 2: After that, we need to create a “CheckButton.php” file inside our extension at the following path

app\code\Vendor\Extension\Block\Adminhtml\AddButton\CheckButton.php

And add the code as given below

<?php

namespace Vendor\Extension\Block\Adminhtml\AddButton;

use Magento\Framework\View\Element\UiComponent\Control\ButtonProviderInterface;

class CheckButton implements ButtonProviderInterface
{
    public function getButtonData()
    {
        return [
            'label'      => __('Check Button'),
            'class'      => 'action-secondary save',
            'sort_order' => 10

        ];
    }
}

Conclusion:

Adding custom action buttons to Magento 2 admin CMS pages is a very practical addition to improve backend efficiency. Whether for viewing, exporting, or triggering workflows, you create your own desired admin UI in an effective way using plugins and Magento’s backend architecture.

Also Learn – Magento 2: How to Add Custom Button in Backend CMS Page Section

Please feel free to let me know in the comments section if you run into any trouble. Share the tutorial with your friends, and stay up to date with more such Magento 2 solutions with us.

Hire Magento Programmer

Happy Coding!

FAQ

  1. What is a custom action button in the CMS Page backend?

A custom action button is an additional button which you are adding to your CMS Page Edit screen in the admin panel of Magento 2. Your custom button can do whatever custom action you want it to, as an example you may want it to redirect to another page; call a controller; export data; call an API, etc. 

  1. Why would I need a custom button in the CMS Page edit section?

You may need a custom button to:

  • Triggering specific business logic (e.g., preview page; export content)
  • Calling a custom controller
  • Redirecting to a customized URL 
  • Improving admin usability or automation
  1. Where exactly will the custom button appear?

The custom button will sit on the CMS Page Edit screen in the admin panel of Magento 2, typically beside the existing “Save”, “Delete”, and “Back” buttons located on the top-right.

Previous Article

Implementing Dark Mode in React Native

Next Article

API Authentication Using JSON Web Tokens (JWT) in Laravel

Write a Comment

Leave a Comment

Your email address will not be published. Required fields are marked *

Get Connect With Us

Subscribe to our email newsletter to get the latest posts delivered right to your email.
Pure inspiration, zero spam ✨