0

I want to add Add Page Builder Editor In Magento 2.4.5 Configuration Section.

Any insight would be helpful.

Thank you :)

1 Answer 1

1

Could you please try below method, hope this will help!

  1. Create a new system configuration section in your module's system.xml file:

    <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
         <system>
             <tab id="yourtab" translate="label" sortOrder="100">
                 <label>Your Tab Label</label>
             </tab>
             <section id="yoursection" translate="label" sortOrder="200" showInDefault="1" showInWebsite="1" showInStore="1">
                 <class>separator-top</class>
                 <label>Your Section Label</label>
                 <tab>yourtab</tab>
                 <resource>Vendor_Module::config</resource>
                 <group id="yourgroup" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
                     <label>Your Group Label</label>
                     <field id="yourfield" translate="label comment" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
                         <label>Your Field Label</label>
                         <frontend_model>Vendor\Module\Block\Adminhtml\System\Config\Field\PageBuilderEditor</frontend_model>
                     </field>
                 </group>
             </section>
         </system>
     </config>
    
  2. Create a new block class PageBuilderEditor.php at Vendor\Module\Block\Adminhtml\System\Config\Field and define the toHtml() method to return the HTML for the Page Builder Editor field:

     <?php
     namespace Vendor\Module\Block\Adminhtml\System\Config\Field;
    
     class PageBuilderEditor extends \Magento\Config\Block\System\Config\Form\Field
     {
         protected function _getElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element)
         {
             $editor = $this->_layout->createBlock(\Magento\Cms\Block\Adminhtml\Page\Edit\Tab\Content::class)
                 ->setData([
                     'id' => $element->getId(),
                     'name' => $element->getName(),
                     'content' => $element->getValue(),
                     'wysiwyg' => true
                 ]);
    
             return $editor->toHtml();
         }
     }
    
3
  • Not Working Getting this error "Invalid Block Type: \Magento\Cms\Block\Adminhtml\Page\Edit\Tab\Content" Commented Apr 6, 2023 at 5:17
  • ok so this class does not exists in Magento2.4.5 because I am using older version of Magento at my localhost... so could you please try to find different class which is responsible for rendering the content of the form. I am trying to install another instance on localhost of latest version and try to find class.. Meanwhile please try at your end. Commented Apr 6, 2023 at 5:52
  • Okay, thanks for your input. +1 Commented Apr 6, 2023 at 9:23

Your Answer

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

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