How to Use JavaScript or PHP Code in a Joomla Article

How to Use JavaScript or PHP Code in a Joomla Article

Normally in a Joomla article, code such as Javascript or PHP will not work. This is for good security reasons. People could do a lot of harm if they were free to use these inside your articles.

However, many advanced users need to use such code. This tutorial will show you how to add a JavaScript or PHP code to a Joomla article.


Step #1. Download the Sourcerer Plugin

  • Go to the Joomla Extensions Directory and find Sourcerer.
  • Click on the "Download" link and you'll be taken to the developer's website where you can download Sourcerer.

download the sourcerer plugin


Step #2. Upload and Install Sourcerer

  • In the Administrator area of your Joomla site, click Extensions > Manage. You will be taken to the Extensions: Install administrative page:

go to extensions manage

  • Click Upload Package File tab.
  • Click Or browse for file green button and find the Sourcerer plugin installation file on your hard drive.
  • Click twice on the plugin package file name to start its installation.
  • Go to Extensions > Plugins. and make sure the following plugins are enabled:
    • Button - Regular Labs - Sourcerer
    • System - Regular Labs - Sourcerer

make sure the plugins are enabled


Step #3. Add JavaScript and PHP codes to a Joomla Article

go to articles add new article

  • Click Content > Articles > Add New Article.
  • Click on the new Code icon at the TinyMCE editor toolbar.

click on the code icon

  • You will see Insert Code popup.

popup box

  • Write your code directly into the box. Make sure that code has the normal opening and closing tags.

enter your code

  • When you're done, click Insert in the top-left corner.

click the insert button

  • Click Save or Save & Close.
  • Now check this article at your site frontend. You should see your JavaScript and PHP code snippets at work.

check the final result


What's Next?


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!

Click here to join the Everything Club