By default, Joomla articles do not support the use of JavaScript or PHP code. This restriction is in place for security reasons, as allowing arbitrary code could pose serious risks to your site.
However, many advanced users need to include such code in their content. This tutorial will walk you through how to safely add JavaScript or PHP code to a Joomla article.
Step #1: Download the Sourcerer Plugin
- Visit the Joomla Extensions Directory and locate the Sourcerer plugin.
- Click the "Download" link to be redirected to the developer's website, where you can download the plugin.
Step #2: Upload and Install Sourcerer
- In your Joomla site's admin dashboard, go to System > Install > Extensions.
- On the "Extensions: Install" screen, click the Upload Package File tab, then upload the Sourcerer plugin installation file.
- Next, go to System > Manage > Plugins.
- Make sure the following plugins are enabled:
- Button - Regular Labs - Sourcerer
- System - Regular Labs - Sourcerer
Step #3: Add JavaScript or PHP Code to a Joomla Article
- Navigate to Content > Articles and open the article where you want to insert your code.
- On the "Articles: Edit" screen, click CMS Content > Code.
- The Code popup window will appear. Paste your JavaScript or PHP snippet into the Code box, then click Insert.
- You will now see the code embedded directly in the article.
- Click Save or Save & Close to store your changes.
- Visit your site's frontend to verify the code is working as expected.
What's Next?
Save $1,000's when you sign up for Joomlashack's Everything Club.
You will get your hands on our extensive range of over 20 extensions, plus legendary support!