Search
Other Sourcerer questions
Forum

Add inline variables

J. Fontaine's Avatar J. Fontaine
I have installed sourcer PRO - my question relates to passing variable(s) to a PHP script:

If I use the 'longhand' syntax, e.g.;

{source}
<?php
$variable = "some_value";
$file = '.\somefolder\my_script.php';
include $file;
?>
{/source}

then my_script.php is able to see/use the value contained in $variable without any issues.

My question is this: How do I pass in $variable using the 'shorthand' syntax, e.g.;

{source include=".\somefolder\my_script.php"}{/source}

This would be FAR simpler - using a single line instead of multiple lines - to accomplish the desired outcome.

Thanks for any replies.

By the way, I have searched the forum for the answer to this question, but found nothing that matches my query.
Peter van Westen's Avatar Peter van Westen ADMIN
Well, your 'longhand' syntax can be shorter:
{source}<?php
$variable = "some_value";
include JPATH_SITE . '/somefolder/my_script.php';
?>{/source}

However, I added a new feature to the Joomla 4 version of Sourcerer that allows you to place inline variables, like
{source include="somefolder/my_script.php" name="John"}{/source}

Please try the latest development version from:
regularlabs.com/development-releases
Please post a rating at the Joomla! Extensions Directory
J. Fontaine's Avatar J. Fontaine
Thank you - Peter! That works for me beautifully.

Confidential information:
(hidden)
Peter van Westen's Avatar Peter van Westen ADMIN
THe issue with the needing to escape characters is now solved in latest dev version:
regularlabs.com/development-releases

The new feature will be included in the next release.
Please post a rating at the Joomla! Extensions Directory
You can only post on the extension support forum if you have an active subscription and you log in

Buy a Pro subscription