Storing a value associated with a component

46 views
Skip to first unread message

xtempore

unread,
May 14, 2012, 9:55:52 PM5/14/12
to Joomla! General Development
I'm working on a component which acts as a wrapper for a 3rd party
product.

As part of the component I want to be able to install the latest
version of that product, and then keep track of the version so that I
can later check whether it is still up to date.

To do that, I need somewhere to store the current product version.

One place I considered is in the parameters for the component, but I'm
not sure how best to do that.

Also I'm not sure what would then happen the next time the user
updates the options. Would my additional parameter get lost?

Any suggestions as to the best place/method for storing internal data
like this>\?

Thanks

Mark Dexter

unread,
May 14, 2012, 10:21:32 PM5/14/12
to joomla-de...@googlegroups.com
Why don't you use the standard method we use for extensions? See:
http://docs.joomla.org/Developing_a_Model-View-Controller_%28MVC%29_Component_for_Joomla!2.5_-_Part_06#Packaging_the_component

http://docs.joomla.org/Developing_a_Model-View-Controller_%28MVC%29_Component_for_Joomla!2.5_-_Part_15

and

http://docs.joomla.org/Developing_a_Model-View-Controller_%28MVC%29_Component_for_Joomla!2.5_-_Part_17.

If you use that, the version number is stored in the #__extensions
table as a value in the manifest_cache column. You can check it just
by reading that row (based on the component name) and unpacking that
column.

Good luck. Mark
> --
> You received this message because you are subscribed to the Google Groups "Joomla! General Development" group.
> To post to this group, send an email to joomla-de...@googlegroups.com.
> To unsubscribe from this group, send email to joomla-dev-gene...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/joomla-dev-general?hl=en-GB.
>

xtempore

unread,
May 15, 2012, 12:33:59 PM5/15/12
to joomla-de...@googlegroups.com
Hi Mark

Thanks for the reply, but I don't get what you are saying.

I need to store the version of the 3rd Party product, NOT the version of my component (that's already taken care of).

I looked through all the MVC example, but found nothing in there that helped me with this problem.

Is there a standardised way of storing extra values that the user cannot change?

Thanks


On Tuesday, 15 May 2012 12:21:32 UTC+10, Mark Dexter wrote:
Why don't you use the standard method we use for extensions? See:
http://docs.joomla.org/Developing_a_Model-View-Controller_%28MVC%29_Component_for_Joomla!2.5_-_Part_06#Packaging_the_component

http://docs.joomla.org/Developing_a_Model-View-Controller_%28MVC%29_Component_for_Joomla!2.5_-_Part_15

and

http://docs.joomla.org/Developing_a_Model-View-Controller_%28MVC%29_Component_for_Joomla!2.5_-_Part_17.

If you use that, the version number is stored in the #__extensions
table as a value in the manifest_cache column. You can check it just
by reading that row (based on the component name) and unpacking that
column.

Good luck. Mark

On Mon, May 14, 2012 at 6:55 PM, xtempore wrote:
> I'm working on a component which acts as a wrapper for a 3rd party
> product.
>
> As part of the component I want to be able to install the latest
> version of that product, and then keep track of the version so that I
> can later check whether it is still up to date.
>
> To do that, I need somewhere to store the current product version.
>
> One place I considered is in the parameters for the component, but I'm
> not sure how best to do that.
>
> Also I'm not sure what would then happen the next time the user
> updates the options.  Would my additional parameter get lost?
>
> Any suggestions as to the best place/method for storing internal data
> like this>\?
>
> Thanks
>
> --
> You received this message because you are subscribed to the Google Groups "Joomla! General Development" group.
> To post to this group, send an email to joomla-dev-general@googlegroups.com.
> To unsubscribe from this group, send email to joomla-dev-general+unsub...@googlegroups.com.

Mark Dexter

unread,
May 16, 2012, 10:46:23 AM5/16/12
to joomla-de...@googlegroups.com
Hi. Sorry I misunderstood. In that case, I'm not aware of any specific
convention. Just create a column in a suitable table and store the
value. Good luck. Mark
>> > joomla-de...@googlegroups.com.
>> > To unsubscribe from this group, send email to
>> > joomla-dev-gene...@googlegroups.com.
>> > For more options, visit this group at
>> > http://groups.google.com/group/joomla-dev-general?hl=en-GB.
>> >
>
> --
> You received this message because you are subscribed to the Google Groups
> "Joomla! General Development" group.
> To view this discussion on the web, visit
> https://groups.google.com/d/msg/joomla-dev-general/-/JVpzCm9kHvwJ.
> To post to this group, send an email to joomla-de...@googlegroups.com.
> To unsubscribe from this group, send email to
> joomla-dev-gene...@googlegroups.com.

Sam Coult

unread,
May 20, 2012, 10:34:25 AM5/20/12
to joomla-de...@googlegroups.com
Another alternative to creating a new column in one of your db tables is to add a hidden field into your component config.xml and update the value of the field when the 3rd party product is updated.  If the field is set to type="hidden" then it will not be overwritten and the user will not be able to see the field when they are in the options. 

xtempore

unread,
May 21, 2012, 3:35:53 PM5/21/12
to joomla-de...@googlegroups.com
Thanks Sam!  I knew there had to be something like that.  I think that's the way to go and I know how to put the hidden field there, I'm just not sure how to update it through code.  Any ideas?

Sam Coult

unread,
May 21, 2012, 4:08:24 PM5/21/12
to joomla-de...@googlegroups.com
I think the easiest thing to do (if you haven't already) would be to add an extension script (see here) and modify the form value in the update function. 

Sam Coult

unread,
May 21, 2012, 4:35:15 PM5/21/12
to joomla-de...@googlegroups.com

Oh and just in case you are unsure how to set the field value I think that you can do something like this:

$registry = new JRegistry();
$registry->set($registrypath, $newvalue);

Mark Dexter

unread,
May 29, 2012, 2:57:52 PM5/29/12
to joomla-de...@googlegroups.com

Hi. Sorry, I misunderstood. In that case, I don't think there is any convention. Just make a place in your database. Mark

To view this discussion on the web, visit https://groups.google.com/d/msg/joomla-dev-general/-/JVpzCm9kHvwJ.
To post to this group, send an email to joomla-de...@googlegroups.com.
To unsubscribe from this group, send email to joomla-dev-gene...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages