Hi,
I need to retrieve module parameters and update the document with a script defining a parameter of my main jQuery script that controls the form.
First I created a Custom Code action at the OnLoad event with the following code:
The problem is that the above code works anywhere else but not inside Custom Code action. Actually the first line ( $module = JModuleHelper::getModule('mod_webhotelier') ) returns an empty object.
Is there any other way to retreive module params?
Thanks,
George
I need to retrieve module parameters and update the document with a script defining a parameter of my main jQuery script that controls the form.
First I created a Custom Code action at the OnLoad event with the following code:
<?php
$module = JModuleHelper::getModule('mod_webhotelier');
$modparams = new JRegistry();
$modparams->loadString($module->params);
$sDate = $modparams->get('startdate');
$doc = JFactory::getDocument();
$doc->addScriptDeclaration('(function($){ $.startDate = "' . $sDate . '"; })(jQuery);');
?>
The problem is that the above code works anywhere else but not inside Custom Code action. Actually the first line ( $module = JModuleHelper::getModule('mod_webhotelier') ) returns an empty object.
Is there any other way to retreive module params?
Thanks,
George
Hi gvouliakis,
If you hunt through the Joomla! Docs you'll find a line of code to load the Module Helper, that should of what you need.
had a quick look . . . please try:
Bob
If you hunt through the Joomla! Docs you'll find a line of code to load the Module Helper, that should of what you need.
had a quick look . . . please try:
jimport( 'joomla.application.module.helper' );
Bob
Dear Bob,
Thanks for your reply!
Before sending the issue I've already tried importing module helper class but the behavior was the same! An empty object is returned.
George
Thanks for your reply!
Before sending the issue I've already tried importing module helper class but the behavior was the same! An empty object is returned.
George
Dear Bob,
SOLVED! SOLVED! SOLVED!
The module was not assigned to be displayed in the menu item that displays the form!!!! 😶
Now everything is Ok! I'm getting module params direct from modules table.
Thanks anyway for your time!
Regards,
George
SOLVED! SOLVED! SOLVED!
The module was not assigned to be displayed in the menu item that displays the form!!!! 😶
Now everything is Ok! I'm getting module params direct from modules table.
<?php
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select('module, params')
->from($db->quoteName('#__modules'))
->where( $db->quoteName('module') .' = '. $db->quote('mod_webhotelier'));
$db->setQuery($query);
$module = $db->loadObject();
$modParams = new JRegistry();
$modParams->loadString($module->params);
$sDate = $modParams->get('startdate');
$eDate = $modParams->get('enddate');
$doc = JFactory::getDocument();
$doc->addScriptDeclaration(';(function($){ $.sDate ="'.$sDate.'"; $.eDate="'.$eDate.'"; })(jQuery);');
?>
Thanks anyway for your time!
Regards,
George
This topic is locked and no more replies can be posted.