5

JModuleHelper has 2 methods available with which you can load modules:

JModuleHelper::getModule();

which takes either a module name / title (e.g. 'Main Menu') or a module 'type' (e.g. mod_menu), and:

JModuleHelper::getModules()

which takes a module position (e.g. 'top').

Is there a way to load a module by both real name AND position, as opposed to using getModules() then running a loop over the result array, checking each title?

2 Answers 2

2

Not to my knowledge. I would do exactly as you suggested.

1

Rather than having to loop through each module I think you can pretty much programmatically specify the parameters you want for the module and just create a new instance altogether for your purpose. I'm not sure if that's reasonable for your application but it might be.

To do this you'd use getModule() to get the module object, then use renderModule with the attribs array of parameters.

In this way you don't really need to know the position, since you're generating the instance on the fly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.