Tag: Javascript
Adding JavaScript to a Joomla Article
by admin on Feb.27, 2011, under Linux
The JCE editor has some nice features, including allowing you to insert php and Javascript into an article. There are however several things which may stop this from working. And judging for the huge number of forum posts on this, it seems that getting this to work is very problematic. Here is what I did to allow the use of Javascript in articles:
- Install the JCE editor plugin
- I recommend uninstalling, or at least disabling, any other PHP / Javascipt editor plugins (Jumi, Sourcerer, etc.) If these are active they tend to compete with each other. Simplify.
- Use the JCE configuration manager to grant permissions to the needed groups
- Configure JCE – set cleanup HTML to no
- In JCE group configuration settings: Allow PHP and Javascript
- This post was the hinge-pin of my issue. Ensure that the default content filter in Joomla is not set to clean content tags! By default in Joomla 1.5.8 even content added by Superadmin is cleaned.
- Navigate to Content → Article Manager.
- Press the Parameters icon in the toolbar to show the Articles – Global Configuration screen.
- Scroll down to Filtering Options, highlight all Filter groups except Super Administrator, and select Filter type of Blacklist (Default)
- If content filtering as noted above is active, you may be able to insert, and even preview, code – but when you apply or save the code will be stripped.
Additional things you may need to do:
- Use the show / hide button in the editor to ensure your code is being inserted correctly. You might even need to follow a process of: click show/hide editor > hide > insert js> click apply> click show/hide > show > save
- If html tags are being added when you save, or other weird issue are occurring, try replacing the editor_plugin.js with a patched version from here and clear browser cache.
- Disable any other content / editor plugins that may be interfering to isolate the problem.
Additional info can be found at the JCE forums.
Another source of information on integrating Javascript and CSS can be found here