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

    Berndi Berndi 30.06.2019 11:45
    The fields %TO_NAME% and %TO_USERNAME% are empty

    Read more...

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

    Berndi Berndi 30.06.2019 11:43
    My fault, I made it

    Read more...

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

    Berndi Berndi 30.06.2019 10:46
    I did. Now I'm asking me how to put the surename into the email... :-|

    Read more...

     
  • NavigationAry - navigate between Joomla menu items like between articles using "prev - next"

    Berndi Berndi 29.06.2019 15:59
    I also miss content in %TO_NAME%

    Read more...

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

    Berndi Berndi 29.06.2019 15:15
    Hi gruz, I have the problem, that when I use the %AUTHOR% tag, the plugin dosen't send the author ...

    Read more...