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.