Blog

Minor Mura Plugin Update

One of the things that has been nagging me for a while about Mura plugins is that when they are installed with a numeric directory.  The programmer in me abstracted one too many times on that one.  It works great with small amounts of plugins, however we envision much of Mura's functionality moving to plugins in the future.  Imagine opening up the plugins directory and seeing directories named 1-52.  Which directory is the one that contains the plugin that you are currently trying to edit?  To remedy this as of version 5.1.300 we have introduced the "package" element to your plugin's config.xml

<plugin><name>Hello World Plugin</name><!-- The package value becomes a part of the directory name where the plugin is installed. --><package>HelloWorldPlugin</package><version>1.1</version><provider>Blue River</provider><providerurl>http://blueriver.com</providerurl><category>Application</category>...</plugin>

The value entered into your <package> element becomes the base of your plugin's install directory.  The package value is combined with the pluginID to make the actual install directory name. So the above plugin install directory would look something like /plugins/HelloWorldPlugin_34/.

The first consequence of this change is that there is a new pluginConfig.getDirectory() method returns the name of the plugin's directory inside of the main /plugins directory.  So if you are building a plugin and want to instantiate a component you would now use:

createObject("component","plugins.#pluginConfig.getDirectory()#.path.to.component").init()

The second consequence is that the /plugin/config.cfm has a line of code that figures out what the current plugin's pluginID is when it has not been explicitly defined.  It does this by parsing the name of the directory two steps up. Since that directory may now have a package prefix it needs to be changed to use listLast() to find the pluginID.

<cfset pluginID=listLast(listGetat(getDirectoryFromPath(getCurrentTemplatePath()),listLen(getDirectoryFromPath(getCurrentTemplatePath()),application.configBean.getFileDelim())-1,application.configBean.getFileDelim()),"_")>

A new convenience method has also been added for this as well.

<cfset pluginID=application.pluginManager.getIdFromDirectory(getDirectoryFromPath(getCurrentTemplatePath()))>

The good news is that any plugin that has been built using the pluginID for all of its directory references will work just fine in the latest version as long as you simple don't apply a package value to it.  This is because if no package is defined the directory will simply be the numeric pluginID. So if your code looked like this it would work just fine.

createObject("component","plugins.#pluginConfig.getPluginID()#.path.to.component").init()

I hope this doesn't throw too many people for a loop.  I think it will well be worth it in the future. 

Comments

Tony Garcia

I think this is a great move, Matt. The one thing I didn't like about the plugin system were the numerical directories and I was about to submit this as a change/enhancement request. Glad you beat me to it!

May 28, 2009, 3:00 PM
Reply
Flag as Spam
Shimju

Matt, Can we develop admin interface for our plugin? Means when we install a plugin , for example shopping cart, I want its adminsitrative functions should appear on Mura CMS admin by default. So in any ways I can extend MuraCMS admin using PLugin?

October 21, 2009, 2:09 AM
Reply
Flag as Spam
Post a Comment

Required Field