Вопрос

i am trying to update the value of parameter . I have a hidden field in xml file, i need to update its value , value is dynamic. I got the parameters using

jimport('joomla.application.module.helper');
$module = JModuleHelper::getModule('mod_name');

I want to avoid the use database query method . Is there joomla predefined function to achieve this task?

thanks in advance

-Neil

Это было полезно?

Решение

Unfortunately Joomla doesn't have an in-built API feature to set a parameter without using a database query. Try the following:

<?php
  jimport( 'joomla.application.module.helper' );
  $module = JModuleHelper::getModule( 'mod_name'); // change module name here

  $params = new JRegistry();
  $params->loadString($module->params);    
  $params->set('param_name', 'value'); // change parameter name and the value

  $db = JFactory::getDbo();
  $query = $db->getQuery(true);   
  $query->update('#__extensions AS a')
        ->set('a.params = ' . $db->quote((string)$params))
        ->where('a.element = "mod_name"'); //change module name here    
  $db->setQuery($query);
  $db->query();
?>

I have tested this code so let me know if it works

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top