Search
Other Sourcerer questions
Forum

Sourcerer on Yootheme Pro

Bernhard Woehrlin's Avatar Bernhard Woehrlin
Hi Peter,

I need your advice. I do have a Yootheme Pro Template where I do want to use this PHP Code in a Text field:
{source}<?php 
use Joomla\CMS\Uri\Uri;
echo base64_encode(Uri::getInstance()); ?>{/source}

After adding this the page breaks and I see this error message:

"syntax error, unexpected token "use""

What am I missing?

Thanks for a hint.

Kind regards,
Bernhard
Peter van Westen's Avatar Peter van Westen ADMIN
You can't use the 'use' statements inside the Sourcerer code. As this code is executed as a function. Not as a separate PHP file.

So simply prepend your namespaced classes with the namespace:
{source}<?php echo base64_encode(\Joomla\CMS\Uri\Uri::getInstance()); ?>{/source}
Please post a rating at the Joomla! Extensions Directory
Bernhard Woehrlin's Avatar Bernhard Woehrlin
Thank you Peter. Very valuable hint, like always. 🙂
Have a nice day!
You can only post on the extension support forum if you have an active subscription and you log in

Buy a Pro subscription