-2

Hi i kinda found the way to display the modules in the component but i am wondering how could i save the parameters through component i mean editing the values in component and saving it. The modules names and paramaters are known in advance. So the calling will be like this

jimport( 'joomla.application.module.helper' );
$module = &JModuleHelper::getModule( "ModuleName");

$params = new JParameter($module->params);

The purpose of doing so is to ease editing certain values for the customer so it is a pain for a newbie to browse all that joomla stuff(in my case).

All in all cant figure out, how to save the params of a module(s)

Bekzod
  • 123
  • 1
  • 2
  • 6
  • So after searching for the solution on the web. It is seems that the parameters are got from the database and after updating the values manually one should simply make a request to db and update corresponding record. – Bekzod Jan 17 '14 at 09:48

1 Answers1

0

Hi this is the code to save the params of a component, module or plugin in Joomla.

It first loads the current params, makes its changes, then saves again; ensure you always load the current params first.

    $mparams = JComponentHelper::getParams( 'com_littlehelper' );
    $params = $mparams->get('params');
    $mparams->set('params.favicons_sourcepath','icons');
    $this->saveParams($mparams, $this->componentName);

private function saveParams($params, $extensionName, $type='component') {
    $db = JFactory::getDBO();
    $query = $db->getQuery(true);
    $query->update('#__extensions AS a');
    $query->set('a.params = ' . $db->quote((string)$params));
    $query->where(sprintf('a.element = %s AND a.%s = %s',
            $db->quote($extensionName),
            $db->quoteName('type'),
            $db->quote($type)
            ));
    $db->setQuery($query);
    return $db->execute();
}

This code comes from my extension LittleHelper published on the JED.

Riccardo Zorn
  • 5,590
  • 1
  • 20
  • 36