I'm trying to get a variable from my module to my template but its not working.
In my modules xml I defined:
<fields name="params">
<fieldset name="basic">
<field
name="imageUrl1"
type="text"
>
</field>
<field
name="imageUrl2"
type="hidden"
>
</field>
...
In my modules tmpl/default.php I do:
$params->set('imageUrl1', $imageSrc)
$params->set('imageUrl2', $imageSrc2)
...
and later in the same file I do:
echo "<p>imageUrl1: {$params->get('imageUrl1')}</p>";
and it shows the correct image link. Everything is fine so far. But then I try to get it from my templates php file and it's not working.
In my index.php I do:
$module = JModuleHelper::getModule('mod_mymodule');
$moduleParams = new JRegistry($module->params);
if ($moduleParams) {
$moduleImage1 = 'url("/' . $newsParams->get('imageUrl1') . '")';
$test = $newsParams->get('otherParam');
}
echo ":root {
--moduleImage1: {$moduleImage1};
--test: {$test};
}";
The thing is: The test variable thats set in the admin module menu is coming through fine but my image URL that I want to have is not going through. The printout is just: --moduleImage1: url("/");
So has anyone any idea how to get this to work? Or even a workaround so I can have the same result?