This major update adds the ability to use Quick Syntaxes to load files, Include Methods, a revamped Editor Button and more.
Sourcerer is the powerful Joomla plugin that enables you to place PHP and any kind of HTML, CSS and JavaScript code right into your content! Not only in your articles, but also in categories, modules, components, the head of the HTML page, etc.
Today, a new major version of Sourcerer has been released, version 8, coming with several new features and improvements, and a completely rewritten documentation, now much more detailed.
Here is a breakdown of everything that's new and improved with Sourcerer 8:
Loading CSS and JavaScript Files PRO
With the Free version of Sourcerer, you could already add CSS styles or JavaScript code to the head of the HTML output, by using Joomla's built-in PHP functions within the {source}
tags.
However, the Pro version of Sourcerer 8 comes with the ability to load CSS or JavaScript files via an easier, shorter syntax, using dedicated attributes.
CSS File
You can now simply use a css
attribute (or style
can also be used), and enter the path of the file:
{source css="path/to/your/file.css"}{/source}
JavaScript File
You can now simply use a js
attribute (or script
can also be used), and enter the path of the file:
{source js="path/to/your/file.js"}{/source}
You can also use the Sourcerer editor button to help you enter your files and code.
Including PHP Files PRO
With the Free version of Sourcerer, you can of course include PHP files by simply using PHP code within the {source}
tags.
However, the Pro version of Sourcerer 8 comes with the ability to include PHP files with an easier, shorter syntax.
You can simply use a php
attribute (or file
can also be used), and enter the path of the file:
{source php="myfiles/file.php"}{/source}
Include Method
The method above will simply include the file.
But if you have a PHP file with classes and functions in it, you will get issues when including the file more than once on your page. In that case it is better to only make it include/require the file once.
When using the short syntax, you can now also specify the Include Method you want to use for the PHP file.
To do this, instead of the generic php
attribute (which equals to include
), you can use one of the following four attributes to specify the Include Method:
{source include="myfiles/file.php"}{/source} {source include_once="myfiles/file.php"}{/source} {source require="myfiles/file.php"}{/source} {source require_once="myfiles/file.php"}{/source}
You can also use the Sourcerer editor button to help you enter a PHP file and easily select your desired Include Method.
Revamped Editor Button
As you may know, you can enter the Sourcerer tags directly into your content. However, to save time typing and remembering what the exact syntax is, Sourcerer comes with a handy editor button.
When clicking on this "Code" button (located below the text input area) you will get a modal popup with the Sourcerer code editor. This can help you enter your code in a dedicated field.
With the Pro version of Sourcerer 8, you now have specific extra tabs at your disposal to more easily insert specific CSS, JavaScript and PHP files and code.
You can simply fill the related fields and, after clicking "Insert", the code with the correct attributes will be automatically generated into your article/content editor.
Also, you can edit code that is already in your article/content item. Simply select the code - including the {source}
tags - and click on the Sourcerer editor button. The selected code and attributes will appear in the Sourcerer editor. And after clicking on the "Insert" button, the new code will replace the selected code.
Improved handling of tag parameters
In addition to the changes listed above, Sourcerer 8 also improves the handling of the other attributes that can be used in the {source}
tags.
To prevent Sourcerer from stripping the HTML code entered in the HTML/Code view of the content (Sourcerer is designed to be used with a WYSIWYG editor), you can now do this by adding raw="true"
attribute:
{source raw="true"}Code in an HTML editor{/source}
Or to make Sourcerer remove the surrounding paragraph tags (that could be added by the editor), you can add a trim="..."
attribute with either a true
(on) or false
(off) value:
<p>{source trim="true"}Surrounding paragraph will be stripped from the output{/source}</p>
And more....
The latest update also comes with various other changes, including:
- Removes example code for editor button
- Removes support for the file-after (or include-after) attribute in the tag
- Removes ability to use file attributes from free version
- Updates translations: de-DE, pl-PL, sv-SE
- Fixes issue with php notice about array to string conversion on certain HikaShop pages
- Fixes some language strings
Read the Changelog for Sourcerer 8 for the full list of improvements and fixes that have been made in the new release.
There are a lot of cool features and options to explore in Sourcerer. Head over to the full Documentation for a complete overview and to find more treasures.