Replace Existing Opencart Editor to New Block Based Editor

Estimated reading time: 1374 words, 9-10 minutes Font: 1,266 Views
Replace Existing Opencart Editor to New Block Based Editor

In the latest version of OpenCart(4.0.2.3), there are four pages that use the editor. In previous versions, only the product and information pages used the editor. Therefore, changing the editor won’t be too complicated. You just need to replace the two important and commonly used pages first. First, download the two files (file name: blockeditor.css and blockeditor.js) for this block based editor, JavaScript(25.59kB 46.6KB) and CSS(7.61KB 16.1KB). Then upload these two files to admin/view/javascript/.

Next, you need to find the form templates for the product and information pages in admin/view/template/catalog/.

Block Based Editor Information Page

Open and edit file information_form.twig and find line 48:

<textarea name="information_description[{{ language.language_id }}][description]" placeholder="{{ entry_description }}" data-oc-toggle="ckeditor" data-lang="{{ ckeditor }}" class="form-control">{{ information_description[language.language_id] ? information_description[language.language_id].description }}</textarea>

replace with this code:

<div id="editor{{ language.language_id }}{{ information_id }}" class="editor"> <button type="button" class="fullscreen">Fullscreen</button> <div id="blocks{{ language.language_id }}" class="blocks"></div> <div class="bottombar"> <button type="button" data-editor="editor{{ language.language_id }}{{ information_id }}" class="addBlock">+</button> <button type="button" data-editor="editor{{ language.language_id }}{{ information_id }}" class="addImg">+Image</button> <button type="button" data-editor="editor{{ language.language_id }}{{ information_id }}" class="addVideo">+Video</button> <button type="button" data-editor="editor{{ language.language_id }}{{ information_id }}" class="addTable">+Table</button> <button type="button" data-editor="editor{{ language.language_id }}{{ information_id }}" data-box="input-description{{ language.language_id }}{{ information_id }}" class="generate">Generate</button> </div> <textarea id="input-description{{ language.language_id }}{{ information_id }}" name="information_description[{{ language.language_id }}][description]" placeholder="{{ entry_description }}" class="results form-control" data-editor="editor{{ language.language_id }}{{ information_id }}">{{ information_description[language.language_id] ? information_description[language.language_id].description }}</textarea> </div>

replace with this latest updated code:

<div id="editor{{ language.language_id }}{{ information_id }}" class="editor" aria-label="Rich text editor"> <div class="editormenu"> <button type="button" accesskey="p" class="preview" aria-modal="true" data-editor="editor">Preview</button> <button type="button" accesskey="f" class="fullscreen" data-editor="editor">Fullscreen</button> </div> <div id="blocks{{ language.language_id }}" class="blocks"></div> <div class="bottombar"> <button type="button" accesskey="n" data-editor="editor{{ language.language_id }}{{ information_id }}" class="addBlock">+</button> <button type="button" accesskey="i" data-editor="editor{{ language.language_id }}{{ information_id }}" class="addImg">+Image</button> <button type="button" accesskey="v" data-editor="editor{{ language.language_id }}{{ information_id }}" class="addVideo">+Video</button> <button type="button" accesskey="t" data-editor="editor{{ language.language_id }}{{ information_id }}" class="addTable">+Table</button> <button type="button" accesskey="g" data-editor="editor{{ language.language_id }}{{ information_id }}" data-box="input-description{{ language.language_id }}{{ information_id }}" class="generate">Generate</button> </div> <textarea id="input-description{{ language.language_id }}{{ information_id }}" name="information_description[{{ language.language_id }}][description]" placeholder="{{ entry_description }}" class="results form-control" data-editor="editor{{ language.language_id }}{{ information_id }}">{{ information_description[language.language_id] ? information_description[language.language_id].description }}</textarea> </div>

Then insert 2 file Block Based Editor url into the file, find at line 174:

<script type="text/javascript"><!-- $('textarea[data-oc-toggle=\'ckeditor\']').ckeditor({ language:'{{ ckeditor }}' }); //--></script>

Replace the block based editor 2 file links.

<link href="view/javascript/blockeditor.css" rel="stylesheet" /> <script type="text/javascript" src="view/javascript/blockeditor.js"></script>

Done replacing the editor for the information form. You can now try using the new block editor in your admin panel.

Block Based Editor Product Page

Open and edit file product_form.twig and find line 72:

<textarea name="product_description[{{ language.language_id }}][description]" placeholder="{{ entry_description }}" id="input-description-{{ language.language_id }}" data-oc-toggle="ckeditor" data-lang="{{ ckeditor }}" class="w-100 position-relative">{{ product_description[language.language_id] ? product_description[language.language_id].description }}</textarea>

Replace with this code:

<div id="editor{{ language.language_id }}{{ product_id }}" class="editor"> <button type="button" class="fullscreen">Fullscreen</button> <div id="blocks{{ language.language_id }}" class="blocks"></div> <div class="bottombar"> <button type="button" data-editor="editor{{ language.language_id }}{{ product_id }}" class="addBlock">+</button> <button type="button" data-editor="editor{{ language.language_id }}{{ product_id }}" class="addImg">+Image</button> <button type="button" data-editor="editor{{ language.language_id }}{{ product_id }}" class="addVideo">+Video</button> <button type="button" data-editor="editor{{ language.language_id }}{{ product_id }}" class="addTable">+Table</button> <button type="button" data-editor="editor{{ language.language_id }}{{ product_id }}" data-box="input-description{{ language.language_id }}{{ product_id }}" class="generate">Generate</button> </div> <textarea id="input-description{{ language.language_id }}{{ product_id }}" name="product_description[{{ language.language_id }}][description]" placeholder="{{ entry_description }}" id="input-description-{{ language.language_id }}" class="results w-100 position-relative">{{ product_description[language.language_id] ? product_description[language.language_id].description }}</textarea> </div>

replace with this latest updated code:

<div id="editor{{ language.language_id }}{{ product_id }}" class="editor" aria-label="Rich text editor"> <div class="editormenu"> <button type="button" accesskey="p" class="preview" aria-modal="true" data-editor="editor">Preview</button> <button type="button" accesskey="f" class="fullscreen" data-editor="editor">Fullscreen</button> </div> <div id="blocks{{ language.language_id }}" class="blocks"></div> <div class="bottombar"> <button type="button" accesskey="n" data-editor="editor{{ language.language_id }}{{ product_id }}" class="addBlock">+</button> <button type="button" accesskey="i" data-editor="editor{{ language.language_id }}{{ product_id }}" class="addImg">+Image</button> <button type="button" accesskey="v" data-editor="editor{{ language.language_id }}{{ product_id }}" class="addVideo">+Video</button> <button type="button" accesskey="t" data-editor="editor{{ language.language_id }}{{ product_id }}" class="addTable">+Table</button> <button type="button" accesskey="g" data-editor="editor{{ language.language_id }}{{ product_id }}" data-box="input-description{{ language.language_id }}{{ product_id }}" class="generate">Generate</button> </div> <textarea id="input-description{{ language.language_id }}{{ product_id }}" name="product_description[{{ language.language_id }}][description]" placeholder="{{ entry_description }}" class="results form-control" data-editor="editor{{ language.language_id }}{{ product_id }}">{{ product_description[language.language_id] ? product_description[language.language_id].description }}</textarea> </div>

Find in same template start line 1456 select this code:

<script type="text/javascript"><!-- $('textarea[data-oc-toggle=\'ckeditor\']').ckeditor({ language: '{{ ckeditor }}' });

Replace this code:

<link href="view/javascript/blockeditor.css" rel="stylesheet" /> <script type="text/javascript" src="view/javascript/blockeditor.js"></script> <script type="text/javascript"><!--

Done replacing the editor for the product form. Now can testing new block based editor at product form in your admin panel. Visit The Editor on Github for live demo.

Key Functionalities of the Editor

Elevate your OpenCart admin experience with simple user-friendly block-based rich text editor, designed to transform your content management process! Transform your content management today!

  1. Block-Based Editing: Effortlessly organize your content into distinct blocks, allowing for easy management and rearrangement of text, images, and multimedia elements.
  2. Rich Text Formatting: Access a wide range of formatting options, including headings, lists, links, and more, to craft visually engaging content without the need for HTML coding.
  3. User-Friendly Interface: Our intuitive design caters to users of all skill levels, making it simple to navigate and utilize the editor’s powerful features.
  4. Seamless Integration: This editor is specifically designed to integrate flawlessly with the OpenCart admin panel, providing a cohesive user experience.
  5. Responsive Design: Enjoy the flexibility of a fully responsive editor, enabling efficient content creation on both desktop and mobile devices.
Found this article helpful? Why not share it on social media and help someone else too?
Twitter (Open in new window) FaceBook (Open in new window)
Posted in categories of Opencart This page was last modified on
Return to all Opencart articles

We'd love to hear from you! Leave a comment with your thoughts.

By creating an account, you agree to our Terms of Service and Private Policy.

Comment Policy