How to display your extension version in Magento admin configuration

Posted on Wed July 20, 2011 by Jeroen Derks There have been 0 comments

To view the version of installed Magento extensions, you can go to Magento Connect Manager. But, then you have to go out of the admin, log in again, and then go back. It works, but I would prefer to see the version information together with the extension configuration in the Magento administration configuration section. This can be easily achieved by 2 or 3 additional modifications.

First, you might add a function to your helper class to retrieve the extension version:

	public function getExtensionVersion()
	{
		return (string) Mage::getConfig()->getNode()->modules->MyCompany_MyModule->version;
	}

Second, you should create a admin block to display this version e.g. in MyCompany/MyModule/Block/Adminhmtl/Version.php:

class MyCompany_MyModule_Block_Adminhtml_Version
    extends Mage_Adminhtml_Block_System_Config_Form_Field
{
	protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
	{
		return (string) Mage::helper('mymodule')->getExtensionVersion();
    }
}

Lastly, you configure the block in your MyCompany/MyModule/etc/system.xml:



	...
	
		
			
	                select
	                MyCompany_MyModule_Block_Adminhtml_Version
	                0
	                1
	                1
	                1
		
	...
	
	...

Of course, then your have to flush the cache, and go to the appropriate admin configuration section.

Please let us know whether you found this article interesting, any comment is welcome!


This post was posted in Magento, Development

Comments