0

I'm creating a plugin that changes the article options programatically. I have been able to change an article's specific properties, like title, category, state, etc, by using JTable.

But I'd like to access the article global options (the one we access on Article Manager > Options), in a way I can change disable for example the Save History option programmatically.

Any idea which class I should instantiate?

Thank you!

1 Answer 1

2

The global parameters for any component are stored in the params column for the component in the #__extensions table. One route would be to load the params using Joomla's component helper class like so:

$params = JComponentHelper::getParams('com_content');

Once you have the params you will be able to get and set them like this:

$params->get('save_history');
$params->set('save_history', 0);

Now all we've done is manage to changed the state of the value in our params object. We still need to insert this back into the DB. Unfortunately there is no "official" means of doing this programaticaly. The easiest would be to manually insert the params object converted to JSON string into the #__extensions table.

Assuming you already have a data object with the appropriate primary key ID for the content component in your extensions table, you can convert the params object to a JSON string, attach to proper field and save to DB like so:

$data->extension_id = 22;
$data->params = (string) $params
JFactory::getDbo()->updateObject('#__extensions', $data, 'extension_id');

Again, although all three Joomla installations I checked did have 22 for the content components primary key extension_id value; you shouldn't assume and should have queried and stored the actual value to use.

Hope this helps.

2
  • Your answer solved my problem. Thanks a lot for your help!!
    – rogcg
    Commented Apr 23, 2015 at 21:19
  • Glad I could help! Commented Apr 23, 2015 at 21:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.