Disabling/Enabling the WYSIWYG Editor in Magento 1.4: A Comprehensive Guide
As a developer working on Magento 1.4, you may have encountered issues with empty <div> tags disappearing from your CMS static blocks or pages when editing. This is often due to the default behavior of the WYSIWYG (What You See Is What You Get) editor.
Understanding the Problem
When you enter code containing empty <div> tags, such as:
<a href="javascript:hide1(),show2(),hide3()"><div class="dropoff_button"></div></a>
The WYSIWYG editor in Magento 1.4 can remove these empty tags when saving the block or page. This results in the code looking like this:
<a href="javascript:hide1(),show2(),hide3()"></a>
The Current Workaround
The current solution involves manually disabling the WYSIWYG editor for each edit session:
- Click the ‘Show/Hide Editor’ button to disable the WYSIWYG.
- Delete any existing code from the editor field.
- Create or obtain clean, non-disrupted code in an external text editor.
- Merge your new code with the existing content using a tool outside of Magento.
- Paste the merged result back into the Magento editor.
- Save the changes.
While this process works, it is cumbersome and error-prone for larger projects or frequent updates to static blocks.
A Better Solution: Disabling WYSIWYG Editor Permanently
To avoid this issue completely, you can disable the WYSIWYG editor entirely at a system level. Here’s how:
-
Backup your database: Before making any changes, ensure you have a recent backup of your Magento 1.4 database.
-
Open your Magento installation: Use an FTP client to navigate to your server where Magento is installed.
-
Locate the
config.xmlfile: You’ll find this in the<your_magento_root>/app/etcdirectory. -
Edit the
config.xmlfile: Open it using a text editor or IDE capable of handling XML files. -
Search for the
html_area_optionsnode: This is usually found inside the<global>node under<config>. -
Add
wymode="op_skin"to thehtml_area_optionsnode: Your updated code should look like this:
<global>
<install date="Tue Mar 15 08:27:49 UTC 2022">
<options>
<remove module="Mage_Adminhtml" />
<remove module="Mage_Core" />
<remove module="Mage_Api2" />
<remove module="Mage_Tag" />
<remove module="Mage_Wishlist" />
<remove module="Mage_Log" />
</options>
</install>
<cron>
<resources>
<default>
<connection>
<use_mysqlnd value="1"/>
<host><![CDATA[localhost]]></host>
<username><![CDATA[root]]></username>
<password><![CDATA[]]></password>
<dbname><![CDATA[magentodb]]></dbname>
<active>1</active>
</connection>
</default>
</resources>
</cron>
<html_area_options>
<wymode>op_skin</wymode>
</html_area_options>
</global>
-
Save the changes: Ensure you save the file with proper formatting.
-
Clear Magento cache: Log in to your Magento admin panel, go to System > Cache Management, and select all options before clicking ‘Flush Cache’.
Verifying Your Changes
After following these steps, any new static block or page created should load directly into raw HTML mode, bypassing the WYSIWYG editor entirely. This means your <div> tags will remain intact when saving.
Conclusion
While Magento 1.4 offers a robust CMS system, the default behavior of the WYSIWYG editor can lead to unexpected issues with empty HTML elements. By disabling the WYSIWYG completely using the config.xml file, you can eliminate this problem and streamline your content management process.
Remember, Magento 1.4 is a legacy system that reached end-of-life in June 2020. For new projects or existing ones seeking long-term support, consider migrating to a more modern platform like Laravel or Magento 2 for enhanced security and performance features. Visit Laravel Company for professional assistance with your migration needs.
This guide provides a practical solution for a common issue faced by developers working on older Magento versions. By understanding the underlying cause and implementing this permanent fix, you can maintain clean, unaltered code in your CMS blocks and pages throughout the lifecycle of your project.