Joomla - Modules within modules
Today I discovered that Joomla modules can act like russian dolls! In that if the mood takes you, it is entirely possible to load and render a module inside another module.
Why would you want to do this I hear you ask. Well if you are developing a module and you want some functionality that is identical to an existing module (core or custom) then it would be inefficient to rewrite the same code. In my case I wanted a login form within a module; so rather than writing my own I loaded the Joomla mod_login module within my module. To do this you need to get all of the modules in a given template position, you can then render any of these modules. The code for this is :
$login = JModuleHelper::getModules('left'); echo JModuleHelper::renderModule($login);
This gets all the modules in the ‘left’ position and then renders the first one.