Sourcerer enables you to place PHP and any kind of HTML style code (including CSS and JavaScript) right in to your content! Not only in your articles, but also in sections, categories, modules, components, META tags, etc.
You can now just place your original codes right into your WYSIWYG editor. The only thing you have to do is surround the code with the Sourcerer tags. Easy peasy!
So now you can also use PHP scripts in your content. That opens up a great deal of possibilities.
Most Joomla! Text Editors will strip parts of your HTML code, like JavaScripts (think of statistics scripts) and movie embed tags. With Sourcerer you won't have these limitations.
Easy to use editor button
Sourcerer comes with a very easy to use editor button. This will help you paste your code in a clean format that will not cause any problems. Also it can give some colors to different types of code.
Sourcerer can read the code you place in your editor. Your editor will add html to the code when you have enters or give code colors and styling. But Sourcerer will strip those (hidden) html tags, so it will not be a problem.
Tags get stripped? Use double bracket syntax
Some editors (i.e. TinyMCE) will strip html style tags when you enter them in the WYSIWYG view. For that reason you can also use double square brackets for the HTML style tags. So if your tags get stripped, use the double bracket syntax.
For instance, instead of doing this:
{source}<strong>Text</strong>{/source}
Use this syntax:
{source}[[strong]]Text[[/strong]]{/source}
The editor button will help you convert code to double bracket syntax (or back to normal tags).
Using html entities
When you want to use html entities in your code, you will notice that most editors will convert them to actual characters when saving.
You can prevent that from happening by using an underscore to escape it, like:
{source}Dani&_euml;lle{/source}
This works from version 2.0.1
Not using a WYSIWYG editor?
Sourcerer is designed to be used with a WYSIWYG editor. It will strip all tags in the html of the content, to prevent styling from messing with the code.
When you do not use a WYSIWYG editor, practically all code will be stripped, which you don't want off course.
To disable Sourcerer from stripping the html code, you can use the '0' parameter imn the {source} tag, like:
{source 0}code in a html editor{/source}
Note: The default Sourcerer syntax tags {source}...{/source} will be used in these examples. The Sourcerer plugin gives you the possibility to change these to whatever you want. So you could - for instance - use shorter syntax tags like {s}...{/s}.
Main syntax
|
|
| Syntax |
{source}your code{/source}
|
| HTML tags |
| Syntax |
{source}<span style="color:red">This text should be red!</span>{/source}
|
| HTML output |
<span style="color: red">This text should be red!</span>
|
| Result in website |
This text should be red! |
| HTML tags (with double square brackets) |
| You can also use the square brackets for the CSS, JavaScript and PHP tags. |
| Syntax |
{source}[[span style="color:red"]]This text should be red![[/span]]{/source}
|
| HTML output |
<span style="color: red">This text should be red!</span>
|
| Result in website |
This text should be red! |
| JavaScript |
| Syntax |
{source}
<script type="text/javascript">
<!--
document.write('This text is placed through <b>JavaScript</b>!');
//-->
</script>
{/source}
|
| HTML output |
<script type="text/javascript">
<!--
document.write('This text is placed through <b>JavaScript</b>!');
//-->
</script>
|
| Result in website |
|
| PHP |
| Syntax |
{source}
<?php
echo 'This text is placed through <b>PHP</b>!';
?>
{/source}
|
| HTML output |
This text is placed through <b>PHP</b>!
|
| Result in website |
This text is placed through PHP!
|
| Combined (HTML, JavaScript and PHP) |
| Syntax |
{source}
<span style="color:red">This text should be red!</span>
<br />
<script type="text/javascript">
<!--
document.write('This text is placed through <b>JavaScript</b>!');
//-->
</script>
<?php
echo '<p>';
echo 'This text is placed through <b>PHP</b>!';
echo '</p>';
?>
{/source}
|
| HTML output |
<span style="color:red">This text should be red!</span>
<br />
<script type="text/javascript">
<!--
document.write('This text is placed through <b>JavaScript</b>!');
//-->
</script>
<p>This text is placed through <b>PHP</b>!</p>
|
| Result in website |
This text should be red!
This text is placed through PHP!
|
| PHP with error |
| Syntax |
{source}
<?php
echo 'Oops, forgot to close the print_r function!';
print_r( $myvar;
?>
{/source}
|
HTML output if NOT logged in as (Super) Administrator |
<!-- Comment - Sourcerer: The PHP code has been removed, because it contains errors. (Log in as (Super) Administrator to show the PHP Debugging.) -->
|
Result in website if logged in as (Super) Administrator |
| Sourcerer PHP Debugging |
| PHP Code |
| 1 | echo 'Oops, forgot to close the print_r function!'; |
| 2 | print_r( $myvar;; |
|
| PHP Error |
| Parse error: syntax error, unexpected ';' in /home/users/nonumftp/nonumber.nl/plugins/system/sourcerer.php(436) : eval()'d code on line 2 |
| To hide this error, turn off PHP Debugging in the Sourcerer plugin parameters. | More about Sourcerer |
|
Please use the forum for support.
Can't get your codes to work? Please try the below suggestions:
Sourcerer does not work. I still see the source tags in the frontend.
- 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 - 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:
Code is stripped when I save the article (like JavaScript and PHP).
- 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) allow you to enter tags in the WYSIWYG view.
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.
- If you use JavaScript or PHP in the tags...
Please see below for more answers.
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 closetags.
PHP should be placed inside the PHP tags:
Or for double bracket syntax:
- 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.
You can also set the PHP debugging option on (in the Sourcerer plugin) to see a report of where the error is.
You can only see the PHP debugging report if you are logged in as (Super) Administrator in the frontend.
Haven't found the answer you were looking for?
Please use the forum for support.
Upgrading to v2
If you are upgrading, you do not have to uninstall the old version. The install package will automatically update Sourcerer to the new version.
If you do uninstall the old version, you will lose all your settings.
Sourcerer 2 is pretty different to version 1. A lot of things have changed that effect the way it works. So if you have been using Sourcerer 1, please take note of these changes.
No more Sourcerer Module
In the Sourcerer 1 you had a special module that could handle the source tags. The new version doesn't need that module and can handle the source tags in any module, and anywhere else in your site for that matter.
When you install Sourcerer 2, all the Sourcerer Modules will be converted to normal Custom HTML modules.
The Sourcerer Module also had a support for a {module} tag to include other modules. With the removal of the Sourcerer Module, that ability is gone too... but...
To get that same functionality back, you can use Modules Anywhere.
No more problems with hidden html code
The Sourcerer forum is filled with people having trouble getting their codes to work (in Sourcerer 1). Usually the problem was due to coping and pasting code, which results in all sorts of markup code messing stuff up.
Sourcerer 2 has no problem with these markup codes between the {source} tags. However, the {source} tags themselves will still have to be free from markup. So this will make the {source} block from working:
But this is no problem:
Other changes
Please read the rest of the information to see how version 2 works. So please read Syntax and the Changelog for more information.
The Sourcerer package installs/updates all necessary extensions, like components, module and plugins. (If the package contains plugins, they will be published after install, so you won't have to do that by hand.)
The package makes use of a special installer. This checks to see if it needs to install the extension(s) or update them. So you can just run this package through the Joomla installer without having to uninstall the older version.
You might experience problems during install for certain setups. In that case you can install the extension(s) manually. Please read the INSTALL.txt in the package...
If you run into any problems, please report this on the forum or let me know via the contact form.
Need more help?
If you need more help, please take a look in the forum.
If you can't find your answer there, please post your question. I am very willing to help!
>> NoNumber! Forum
Changelog
|
Changelog
+ = Added ! = Removed ^ = Changed # = Fixed
09-Feb-2009 : v2.4.2
^ Reduced number of database queries
# Fixed error on some articles when no author is set
# Fixed issue with deprecated syntax for php 5.3+
# Fixed issue with preg_match_all error in some cases (when article author is not set)
26-Jan-2010 : v2.4.1
# Fixed issue with Missing argument errors in feeds
# Fixed location of Joomla! DTD files
19-Jan-2010 : v2.4.0
+ Added Commercial License Code support
^ Moved functions to helper file
^ Moved elements to seperate global plugin (also used by other extensions)
^ Added extra html to code helpers output to prevent editor stipping tags
# Fixed padding on editor button in fronted when no icon is shown
# Fixed issue with preservation of indentation on selection in IE
27-Nov-2009 : v2.3.2
# Fixed issue with Sourcerer codes being handled in Joomfishplus edit page
# Fixed issue with php errors when article does not pass security level
11-Nov-2009 : v2.3.1
^ Changed display of Sourcerer PHP Debugging
# Fixed issue with PHP code breaking if last line is a comment
10-Nov-2009 : v2.3.0
+ Added option to define editor button text
+ Added option to show/hide editor button icon
^ Changed size of modal window for Sourcerer editor to maximum
# Fixed issue with code from Sourcerer editor being messed up by html tags when using IE
28-Oct-2009 : v2.2.3
^ Changed file encoding to UTF-8
^ Changed output of code from Sourcerer editor when no color is kept (cleaner)
^ Changed method of indentation to output less html (1 image for 4 spaces)
# Fixed issue with wrong comment in html when PHP is not enabled or doesn't pass security
09-Oct-2009 : v2.2.2
^ Changed the update check
# Fixed issue with changes in default settings not working
17-Sept-2009 : v2.2.0
+ Added option to preserve indentation of code in the content
^ Completely change the editor button popup with special editor (EditArea)
^ Cleaned up some code
# Fixed issue with errors when article author (created_by) does not exist
# Fixed issue with editor button popup not working on all setups
07-Aug-2009 : v2.1.8
# Fixed issue with errors in feeds when using K2
05-Aug-2009 : v2.1.7
^ Made the toggling in settings faster and more stable
# Fixed issue with textareas overlapping in settings (in IE)
01-Aug-2009 : v2.1.6
# Fixed issue with html_entity_decode error on some setups (php4)
30-July-2009 : v2.1.5
# Fixed issue with code styling tags not all being removed in final output
27-July-2009 : v2.1.4
^ Changed code to make the Sourcerer editor button window work faster/better
# Fixed issue with code in Sourcerer editor button window not working properly in IE
# Fixed issue with Sourcerer editor button window not being accessible in some setups
# Fixed issue with SRC tags sometimes showing
17-July-2009 : v2.1.3
# Fixed issue with error in Sourcerer editor button popup page
12-July-2009 : v2.1.2
^ Changed sliding toggle option (in admin settings) to work better in IE8
# Fixed issues with php4 incompatibility
04-July-2009 : v2.1.1
# Fixed issue with preg_replace error
03-July-2009 : v2.1.0
+ Added option to disable Sourcerer temporarily via url &disable_sourcerer=1
+ Added 3 ready available variables: $article, $user, $database
^ Made code a lot lighter (less memory load)
^ Changed the textarea element (made it resizable)
^ Moved frontend language to a separate file
# Fixed some comments not being placed correctly
# Fixed issue with code in articles being executed twice
26-June-2009 : v2.0.1
+ Added syntax to escape html entities with underscore
+ Added fields to set the default rgb values for code coloring
+ Added code coloring for html
^ Changed the way the code is colored (more straightforward)
^ Changed auto installer
# Fixed issue with special characters and &...; characters not being translated correctly
12-June-2009 : v2.0.0
+ Added option to disable html cleanup with {source 0} tag
+ Added a lot of options to the editor button
+ Added a check to see if system plugin is installed in the editor button settings page
+ Added a wizard
^ Changed the editor button from a simple insert to a complete Code Helper
^ Changed the way PHP gets parsed: Now you can break PHP statements over multiple PHP blocks
^ Changed installation procedure (automatic installer/updater)
^ Changed the versioncheck
^ Changed different administrator elements
^ Changed the output of the PHP Debugging and enabled it only for (Super) Administrators
^ Changed the link for more information
^ Changed a lot of language code
^ Changed tag syntax setting (can now only set word)
! Removed (the need for) the Sourcerer module and its settings
! Removed the settings for Categories / Sections (is now together with Article settings)
! Removed update icon in administrator toolbar
! Removed security check on article modifier (so now only checks creator)
# Fixed issue with styling breaking the code (all html tags get stripped)
# Fixed issue with PHP vars over multiple Sourcerer tags
# Fixed issue with using the {source} tags in paragraphs
# Fixed issue with editor button breaking if plugin was not installed
# Fixed issue with editor button settings not working if plugin was disabled
# Fixed issue with editor button image not working on frontend
# Fixed issue with option to not use example code not working
26-Sept-2008 : v1.0.0
+ First stable release
+ Added support for defining vars over multiple Sourcerer tags
^ Changed a lot of code to standardize syntax
^ Changed the versioncheck
03-July-2008 : v0.1.5
# Fixed issue with params not being initialized properly (resulting in bug for components)
02-July-2008 : v0.1.4
# Fixed an issue with special characters inside the Sourcerer tags
25-June-2008 : v0.1.3
# Fixed a bug with the components compatibility
14-June-2008 : v0.1.2
^ Optimized the code a bit more
^ Changed the bracket syntax for tags to double brackets. This because single brackets can be used in JavaScript and PHP.
09-June-2008 : v0.1.1
# Fixed some issues with security levels regarding articles
02-June-2008 : v0.1.0
+ First release (based on AnyTags! v2.2.2)
|