How to update component parameters? (want to update a 'lastupdated' parameter when I alter other component data in backend)

78 views
Skip to first unread message

Chris Walsh

unread,
Feb 2, 2012, 7:12:41 AM2/2/12
to joomla-...@googlegroups.com
Hello All,

Apologies for the double post.  I've posted into The Joomla! Development Forum (Coding) but it says to use this forum despite that fact that people are still posting over there.  I am not sure which forum is right.
Anyway...

I have built a backend component which includes a list 'view' similar to many other backend components. 

I have successfully made one of the columns editable and savable similar to how the 'ordering' column column works with the 'save' tag.  Clicking save updates all the parameters back to each of the list items.

The problem I am having is updating the 'lastupdated' component option (params) whenever a save occurs.  I can get the component options in my 'save' model function using:
[code]
$component_params = &JComponentHelper::getParams( 'com_portfolios' );
//var_dump($component_params);
var $lu = $component_params->get('lastupdated');
[/code]

However, although JRegistry (the class returned by the 1st line) contains a setValue() method, it doesn't appear to have a save() method to write the amended values back to the component options (params) in the database.  None of the derived classes appear to fill this gap either.

Reading Component Parameters article also suggests accessing the parameters this way might be better as I am not interested in menu or item overrides (but I think this isn't my main issue - writing back is):
[code]
  $component = JComponentHelper::getComponent( 'COMPONENT_NAME' );
  $params = new JParameter( $component->params );
[/code]
Is there a tidy J! interface for doing this?

Thanks,
Chris

Sam Moffatt

unread,
Apr 22, 2012, 3:20:01 PM4/22/12
to joomla-...@googlegroups.com
JRegistry itself doesn't define a save mechanism, it's just a
container for structured data with serialisation and deserialisation
techniques. You will have to update the tables yourself manually.

This is done normally by com_config's component model:
https://github.com/joomla/joomla-cms/blob/master/administrator/components/com_config/models/component.php

You can see there it uses a JTableExtension to store the information
after doing some processing (it's designed to come from a form). In
your case, grabbing the JTableExtension and pushing the params from
the JRegistry into it should do the trick.

Cheers,

Sam Moffatt
http://pasamio.id.au

> --
> You received this message because you are subscribed to the Google Groups
> "Joomla! CMS Development" group.
> To view this discussion on the web, visit
> https://groups.google.com/d/msg/joomla-dev-cms/-/gWA3WCS1X04J.
> To post to this group, send an email to joomla-...@googlegroups.com.
> To unsubscribe from this group, send email to
> joomla-dev-cm...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/joomla-dev-cms?hl=en-GB.

Reply all
Reply to author
Forward
0 new messages