Show Version After Extension Update

40 views
Skip to first unread message

Mark Dexter

unread,
Apr 20, 2012, 10:40:30 PM4/20/12
to Joomla! CMS Development
I've been playing around with the one-click extension update. It seems
like it would be nice to show the new extension version in the success
message.

We can do this now if we hard-code the version in a language string.
But it seems like we should be able to get the version number out of
the extension manifest. We have the the $parent object, which is an
instance of JInstallerComponent (in my example). This has a protected
field called manifest that has the old and new versions in it.

Would it make sense either (a) make this public so we could get the
new version with $parent->manifest->getAttribute('version') or (b) add
a getVersion() method to the class? Or maybe there is an easier way to
get the extension version from here?

Has anyone else had this issue? Any thoughts on this will be
appreciated. Thanks.

Mark

Sam Moffatt

unread,
Apr 21, 2012, 2:52:54 AM4/21/12
to joomla-...@googlegroups.com
Without checking $parent->manifest->getAttribute('version') will
likely be the version in the root tag which is supposed to be the
target Joomla! version (though not really used except in 1.0 to flag
legacy IIRC). You need to get the version tag from the file
($parent->manifest->version or similar) instead.

Cheers,

Sam Moffatt
http://pasamio.id.au

> --
> You received this message because you are subscribed to the Google Groups "Joomla! CMS Development" group.
> 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.
>

Mark Dexter

unread,
Apr 21, 2012, 11:23:22 AM4/21/12
to joomla-...@googlegroups.com
The point is that this does not work at present because that field is
protected. Would it make sense to change that to public so we can show
the version in the success message? Mark

Sam Moffatt

unread,
Apr 21, 2012, 3:12:45 PM4/21/12
to joomla-...@googlegroups.com
We already have a public JInstaller::getManifest() already because the
adapters are distinct classes so cannot access protected properties of
the installer.

Cheers,

Sam Moffatt
http://pasamio.id.au

Mark Dexter

unread,
Apr 22, 2012, 1:02:18 PM4/22/12
to joomla-...@googlegroups.com
Actually, it turns out to be pretty easy after all. Inside the script, you can use this to get the new version number:

$parent->get('manifest')->version

So, in the helloworld example, you can do something like:

echo '<p>' . JText::sprintf('COM_HELLOWORLD_UPDATE_TEXT', $parent->get('manifest')->version) . '</p>';

and then use %s inside the language tag like:

COM_HELLOWORLD_UPDATE_TEXT="Hello world now updated to version %s."

Mark

>>> To post to this group, send an email to joomla-dev-cms@googlegroups.com.
>>> To unsubscribe from this group, send email to joomla-dev-cms+unsubscribe@googlegroups.com.


>>> For more options, visit this group at http://groups.google.com/group/joomla-dev-cms?hl=en-GB.
>>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups "Joomla! CMS Development" group.

>> To post to this group, send an email to joomla-dev-cms@googlegroups.com.
>> To unsubscribe from this group, send email to joomla-dev-cms+unsubscribe@googlegroups.com.


>> For more options, visit this group at http://groups.google.com/group/joomla-dev-cms?hl=en-GB.
>>
>
> --
> You received this message because you are subscribed to the Google Groups "Joomla! CMS Development" group.

> To post to this group, send an email to joomla-dev-cms@googlegroups.com.
> To unsubscribe from this group, send email to joomla-dev-cms+unsubscribe@googlegroups.com.

>>> To post to this group, send an email to joomla-dev-cms@googlegroups.com.
>>> To unsubscribe from this group, send email to joomla-dev-cms+unsubscribe@googlegroups.com.


>>> For more options, visit this group at http://groups.google.com/group/joomla-dev-cms?hl=en-GB.
>>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups "Joomla! CMS Development" group.

>> To post to this group, send an email to joomla-dev-cms@googlegroups.com.
>> To unsubscribe from this group, send email to joomla-dev-cms+unsubscribe@googlegroups.com.


>> For more options, visit this group at http://groups.google.com/group/joomla-dev-cms?hl=en-GB.
>>
>
> --
> You received this message because you are subscribed to the Google Groups "Joomla! CMS Development" group.

> To post to this group, send an email to joomla-dev-cms@googlegroups.com.
> To unsubscribe from this group, send email to joomla-dev-cms+unsubscribe@googlegroups.com.

Reply all
Reply to author
Forward
0 new messages