Star InactiveStar InactiveStar InactiveStar InactiveStar Inactive
 
Multithumb found errors on this page:

There was a problem loading image http://static.xscreenshot.com/2016/03/07/16/screen_4063dcccbdc913660331e2914070b38e
There was a problem loading image http://static.xscreenshot.com/2016/03/07/16/screen_4063dcccbdc913660331e2914070b38e

screen_4063dcccbdc913660331e2914070b38eI needed to update a plugin settings upon an extension installation. Here is a sample of my code.

The problem was a little harder to solve, because of the nested objects in the params object.

The screenshot is hear for better understanding of my data structure.

// Get extension table class
$extensionTable = JTable::getInstance('extension');
// Find plugin id, in my case it was plg_ajax_ajaxhelpary
$pluginId = $extensionTable->find( array('element' => 'ajaxhelpary', 'type' => 'plugin') );
$extensionTable->load($pluginId); // Get joomla default object $params = new JRegistry; $params->loadString($extensionTable->params, 'JSON'); // Load my plugin params. $list_templates = json_decode($params->get('list_templates')); // list_templates is an object if array, so I need to encode it once more here
if (!empty($params->get('list_templates')) && $list_templates === NULL) { // The default joomla installation procedure doesn't store defaut params into the DB in the correct way
    $params_tmp = str_replace("'",'"',$params->get('list_templates'));
    $list_templates = json_decode($params_tmp);
} // Some my special code simply to illustrate and help to understand $update_ajaxhelpary = true; foreach ($list_templates->plg_name as $key=>$plg_name) { if ($plg_name == 'notifyarticlesubmit') { unset($list_templates->plg_name[$key]); unset($list_templates->plg_type[$key]); unset($list_templates->scope[$key]); unset($list_templates->function[$key]); } if ($plg_name == $this->plg_name) { $update_ajaxhelpary = false; } } foreach ($list_templates as $k=>$array) { $list_templates->$k = array_values($array); } if ($update_ajaxhelpary) { $list_templates->plg_type[] = $this->plg_type; $list_templates->plg_name[] = $this->plg_name; $list_templates->function[] = '_ajaxRun'; $list_templates->scope[] = 'both'; } // By here my object is ready to be saved $list_templates = json_encode($list_templates); // Prepare it to the database $params->set('list_templates',$list_templates); // Set to parameters $extensionTable->bind( array('params' => $params->toString()) ); // Bind to extension table // check and store if (!$extensionTable->check()) { $this->setError($extensionTable->getError()); //~ return false; } if (!$extensionTable->store()) { $this->setError($extensionTable->getError()); //~ return false; }

Please register to post comments.

Found a typo? Please select it and press Ctrl + Enter.
FaLang translation system by Faboba
ОУН-УПА: легенда спротиву Українська Дивізія «Галичина» Зиновій Книш: спогади й матеріали до діяння УВО і ОУН Реаніматор електронних текстів Забуттю не підлягає 1917-1991

See a typo?

Select the text block and press

CTRL+Enter

Comments

  • NotificationAry - get emails on Joomla content is submitted, added or changed

    gruz gruz 22.05.2019 12:02
    http://gruz.ml/images/x/2019_05_22_12_00_08_lm.png

    Read more...

     
  • NotificationAry - get emails on Joomla content is submitted, added or changed

    Berndi Berndi 22.05.2019 11:35
    How can I activate this? It istn't shown on my Joomla! installation (3.9.6) ...

    Read more...

     
  • NotificationAry - get emails on Joomla content is submitted, added or changed

    gruz gruz 22.05.2019 10:50
    It's implemented http://gruz.ml/images/x/2019_05_22_10_28_53_oa.png

    Read more...

     
  • NotificationAry - get emails on Joomla content is submitted, added or changed

    Berndi Berndi 22.05.2019 10:15
    Hello Gruz, thank you for this great Joomla!extension. Would it be possible to give the writer the ...

    Read more...

     
  • NotificationAry - get emails on Joomla content is submitted, added or changed

    gruz gruz 30.04.2019 12:50
    1. You can build mail body using PHP. So you are able to write PHP code in a way to check the language ...

    Read more...