Sourcerer

Place any code in Joomla!

  • Last updated: 13 Sep 2019
  • Version: 8.2.0
  • Types: System plugin Editor button plugin
  • Joomla rating: 100%

Frequently Asked Questions about Sourcerer

I'm getting fatal PHP errors about redeclaring functions in Joomla 3.8.0

Due to a change (bug!) in Joomla 3.8.0, plugins are triggered twice over the same article content. This will cause Sourcerer to execute the code you place in the content twice as well.

This is fixed with Joomla 3.8.1, so make sure you update your Joomla version.

You can also solve this by placing any classes and/or functions you have in your custom php code you place via Sourcerer in a separate file.
Then you can use require_once in your Sourcerer code to load these classes and/or functions.

This has the added benefit that you can reuse these custom classes/functions in other places by simply loading them in where you need them.

Also it is usually easier to edit/maintain/test code in a separate php file than having it inside {source} tags in an article.

Also see the more in-depth infromation on how to include files via Sourcerer.

The {source} tags are not being converted

The Sourcerer plugin is not published

Check if the Sourcerer plugin is published. Go to Extensions >> Plugin manager and search for the system plugin "System - Regular Labs Sourcerer". Then publish it.

There is markup code in the Sourcerer syntax tags

Sourcerer has no problem with markup codes between the {source} tags. However, the {source} tags themselves will have to be free from markup. So this will make the {source} block from working:

<span>{</span>source}

Remove the extra styling or other html tags around and in the {source} tags that might cause problems.

Code is stripped when I save the article

Make sure you are using the WYSIWYG view of your editor.

Some editors remove tags you enter in the editor (even if not in html view).

To prevent tags from being stripped, use the double bracket syntax. So instead of <tag>, do [[tag]].

Some editors (like JCE) do allow you to enter tags in the WYSIWYG view, but you may have to change some settings in the editor.

Code is stripped on the frontend (in the editor the code is all there)

The security level prevents the use of Sourcerer

You can set certain security settings in the Sourcerer plugin. This way you can prevent certain user group levels and certain content types to not allow the use of Sourcerer. Please look in the html output source of you site to see if you have a Sourcerer comment that tells you this is the case.

Using JavaScript or PHP in the tags?

Some editors remove tags you enter in the editor (even if not in html view).

To prevent tags from being stripped, use the double bracket syntax. So instead of <tag>, do [[tag]].

Some editors (like JCE) do allow you to enter tags in the WYSIWYG view, but you may have to change some settings in the editor.

JavaScript is not working

You have forgotten the script open and close tags

JavaScript should be placed inside the script tags:

<script type="text/javascript">...</script>

Or for double bracket syntax:

[[script type="text/javascript"]]...[[/script]]

The security level prevents the use of JavaScript

You can set certain security settings in the Sourcerer plugin. This way you can prevent certain user group levels and certain content types to not allow the use of JavaScript. Please look in the html output source of you site to see if you have a Sourcerer comment that tells you this is the case.

PHP is not working

You have forgotten the PHP open and close tags

PHP should be placed inside the PHP tags

<?php ... ?>

Or for double bracket syntax:

[[?php ... ?]]

The security level prevents the use of PHP

You can set certain security settings in the Sourcerer plugin. This way you can prevent certain user group levels and certain content types to not allow the use of PHP. Please look in the html output source of you site to see if you have a Sourcerer comment that tells you this is the case.

There are errors in your PHP code

Sourcerer will not execute your PHP code if it has errors. You can check if you have errors by looking in the html output source of you site to see if you have a Sourcerer comment that tells you this is the case.

What to do with <head> or <body> tags?

You SHOULD NOT add any main html structure tags (<html>, <head>, <body> tags) inside your content.
Joomla already creates the full html structure. So if you place structure tags in your content, you will get invalid html, which can cause all sorts of issues.

When copying code from some ready-made html/script, make sure you only place the part that is inside the <body> tags into your content.

If you need to add css or javascript to the head of your page, you can do so via PHP. See: How to add code to the head of the HTML page.

Quotes are escaped (\") in the editor

This is caused by an incorrect server setting. The Magic Quotes GPC php settings should be switched off. If you don't know how to change that setting, ask your host.

I get a 'Parse' error / 'runtime-created function' error

This means something is wrong with the php code you have placed through Sourcerer.
Double check your own code for problems.

I want to prevent others from using the {source} tag

The easiest way to prevent this is to change the tag syntax name to something other than 'source'. You can change this in the Sourcerer system plugin settings.

For instance, if you change this to 'mycode', then the {source} tags no longer work and you have to use {mycode}...{/mycode}

In the Pro version you have extensive security settings to (dis)allow certain things for different user groups. So you can fine-tune the ability to use the Sourcerer tags and types of code.

Installation

How can I install/upgrade Sourcerer?

You can either install Sourcerer by using the core extension manager available in the Joomla! Administrator Control Panel, or by using the powerful Regular Labs Extension Manager.

Note: When updating Sourcerer, you do not need to uninstall it first. The package will update all the files automatically.

Keep in mind that when you update to a major new version (or uninstall first), you might lose some configuration settings.

Sourcerer won't install...

If you have problems installing Sourcerer, please try the manual installation process as described here: docs.joomla.org/Installing_an_extension

How can I uninstall Sourcerer?

You can either uninstall Sourcerer by using the core extension manager available in the Joomla! Administrator Control Panel, or by using the powerful Regular Labs Extension Manager.

If you no longer use any Regular Labs extensions, you can also uninstall the Regular Labs Library plugin by using the Joomla! core extension manager.

What are the minimum requirements?

Sourcerer will only work correctly if your setup meets these requirements:

  • Up-to-date version of Joomla:
    • Joomla 3.9.0 or higher
  • PHP 5.6 or higher
  • MySQL 5 or higher

Important: I can only provide support for setups that:

  • meet the above requirements;
  • do not have extension files or Joomla! core files which have been altered in any way.

Where can I download earlier versions?

You have access to all previous free versions of all extensions on this website.

If you have a subscription to an extension, you can also download any previous pro version of that extension.

If you do not have a valid subscription, you can download any pro version that is older than 1 year.

You can find old versions in the changelog.

Note: Please note that I am unable to provide support on old versions! (whether you have a subscription or not).

How can I downgrade to an earlier version of Sourcerer?

If for some reason you need to install an older version, it is best to uninstall the extension first.

You will also have to uninstall the Regular Labs Library system plugin.

After that you can simply install the older version zip file using the Joomla! installer.

Note: Please note that I am unable to provide support on old versions!

Licensing

Under what license are Regular Labs extensions released?

All free and paid Regular Labs extensions are released under the Open Source GNU GPL v2.0 license.

See the Terms & Conditions for additional terms.

Regular Labs Library

What is the Regular Labs Library?

The Regular Labs Library is a Joomla! library and system plugin that is installed along with every Regular Labs extension.

This plugin contains all the common functions and language strings that the Regular Labs extensions use.

If you use any Regular Labs extensions, this plugin must be installed and published. They will not function correctly or they will not function at all without it.

Do I still need the NoNumber Framework plugin?

The NoNumber Framework has been replaced with the Regular Labs Library.

It is however not possible for my installer to check if a user has any custom code (in custom extensions, overrides or templates) that is using and relying on functionality from the NoNumber Framework.
This is the reason the NoNumber Framework does not get uninstalled automatically.

The NoNumber Framework can safely be uninstalled if your do not have any custom code using it.

More Questions

I cannot find an answer to my question

Is there no answer to your question in this list, please try out these options:

  • General FAQs
    For general questions see the Pre-Sale Questions & Answers.
  • Tooltips
    All settings/options for the installed extensions have tooltips that explain what that setting is for. That should give you enough information to know how to use it.
  • Google
    Google is your friend! If you have some problem, get an error, have a question, try out Google. It usually gives you enough feedback to find an answer.
  • Support Forum
    For more specific questions or feedback, please use the Support Forum.
    For extension support you will need a valid subscription.
    For Bug Reports and Pre-Sale questions you do not need a subscription.