Jump to content


new function Module::getModuleRoute($language)

Module Custom

  • Please log in to reply
1 reply to this topic

#1 windsor


    Advanced Member

  • Moderators
  • 272 posts
  • LocationTampa, Florida USA

Posted 25 July 2013 - 01:09 AM

Currently, there seems to be a convention/assumption that the Module::getPluralModuleLabel($language) function will always return the name of the module. 


This is not the case if you create a custom module.  Especially if you want to want to keep it type-safe in zurmo, you can add a prefix to the module name.


for example: if you want to add a custom module that processes invoices, you don't necessarily want to name the module directory 'invoices', instead you can name it 'customInvoices' or 'abcInvoices' or  prepend some other prefix so that you can avoid a future name collision if the zurmo dev team decides later on down the road to enhace zurmo with invoice functionality.





module directory name = '.../app/protected/modules/abcInvoices'


module  =  '.../app/protected/modules/AbcInvoicesModule.php'


module name = 'AbcInvoicesModule'


singular module label = 'Invoice'


plural module label = 'Invoices'


default url route = '.../zurmo/index.php/abcInvoices/default'



So currently in each module, you can find code that looks like this:


protected static function getSingularModuleLabel($language)
            return Zurmo::t('AbcInvoicesModule', 'Invoice', array(), null, $language);

protected static function getPluralModuleLabel($language)
            return Zurmo::t('AbcInvoicesModule', 'Invoices', array(), null, $language);

So this is currently existing functionality and it will allow you to specify a "label" for the module, which will show up in the views.  Which is Great!


However; - One should *not*  attempt  to construct a url route ( i.e. module/controller/action) from the getPluralModuleLabel() , b/c if you are using a prefix on your custom module name and/or you have camel case in the module directory name, then the route will be invalid.


So... It would be helpful to have a method in the core that always returns a "safe" and correct string that represents the actual  route of the module. Then everyone would not have to do something like this:.. ZurmoWalkthroughBaseTest::checkCopyActionResponseAttributeValues(..), which also won't work for a camel cased module directory name.


in the above example it should just return 'abcInvoices', which should correspond with the directory name of the module under app/protected/

#2 raysto


    Zurmo Team

  • Administrators
  • 1,973 posts

Posted 30 July 2013 - 02:39 PM

OK, thanks for bringing this up. Perhaps we can chat about it during the Dev Session in 20 minutes.

Ray Stoeckicht
Zurmo Team
Try Zurmo Pro

Also tagged with one or more of these keywords: Module, Custom

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users