hi,
I've run in a problem with module which is using com_ajax getting the correct params. As with ajax the helper method will be triggered async there are only two ways to get the module's params: Either via
JModuleHelper::getModule or via Database queries to #__modules. But If you have multiple instances of your module both methods are not applicable as with getModule or with db-query you will need to know the title (which you don't) to get the correct module with its params.
I've solved/circumvented this Problem by:
This solution would not be neccesary if Joomla would provide a means for getting the correct module if you have multiple module instances.
I think, Joomla core should provide in addition to the params the current module-id to a module.php. I know this problem is sofar only applicable to ajax. But more extensions will exploit Joomla's core ajax interface and will require a solution for this problem.
Labels |
Added:
?
|
Category | ⇒ | Components |
Category | Components | ⇒ | Modules |
just add one more parameter with module title to the request, eg: &title=blabla
and JModuleHelper::getModule
will give you what you want:
$app = JFactory::getApplication();
$module = JModuleHelper::getModule('mod_mymodule' , $app->input->getString('title'));
var_dump($module->params);
hi,
you cannot use $module = JModuleHelper::getModule('mod_mymodule' , $app->input->getString('title')); - I tested this:
Solution with $module->id does work!!! This fixes my problem Thanks a lot.
Status | New | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2015-03-01 10:11:02 |
Hi,
I ran into the same issue. Wouldn't it be much better if we could call JModuleHelper::getModule() with the module id instead of it's title? Using an alphanumeric string is less reliable imho that passing an id. I tried to pass the title in the com_ajax request (along with option, cmd etc.) and it doesn't work, but passing an id does work. So as for now I'm passing the id and then running and extra query in order to retrieve the title again. A bit of a waste of resources.
Passing the module title in the url as suggested by Fedik also seems a bit of a detour to me.
Kind regards, Frits
Am 18.12.2015 um 16:20 schrieb oorzaak:
Hi,
I ran into the same issue. Wouldn't it be much better if we could call
JModuleHelper::getModule() with the module id instead of it's title?
Using an alphanumeric string is less reliable imho that passing an id.
I tried to pass the title in the com_ajax request (along with option,
cmd etc.) and it doesn't work, but passing an id does work. So as for
now I'm passing the id and then running and extra query in order to
retrieve the title again. A bit of a waste of resources.Passing the module title in the url as suggested by Fedik also seems a
bit of a detour to me.Kind regards, Frits
_This comment was created with the J!Tracker Application
https://github.com/joomla/jissues at
issues.joomla.org/joomla-cms/6231
https://issues.joomla.org/tracker/joomla-cms/6231.—
Reply to this email directly or view it on GitHub
#6231 (comment).hi,
I agree to your solution - there should be a method to get module's
properties via it's id and/or title. e.g.
"JModuleHelper::getModule($title, $id)"
MfG
Joachim Schmidt
Nußbachstr. 3
35641 Schöffengrund
Tel.: 06085-971030
Mobil: 0170-5046625
Omnis enim res, quae dando non deficit, dum habetur et non datur, nondum
habetur, quomodo habenda est.
(Wenn eine Sache nicht gemindert wird, da man sie mit anderen teilt, ist ihr Besitz unrecht, solange man sie nur allein besitzt und nicht mit anderen teilt)
Hi jschmi01,
Thx for your reply. Would there be some way to reopen this issue, as it is closed now?
Frits
Up up!
"JModuleHelper::getModule($name, $id)"
My question would be why you need the module params in com_ajax. Can't you pass the needed information in the AJAX request? That's what I would do.
If you for some reason really need the module id in the module output itself, just use
$module->id
. The$module
object is available in each module. No need to hack something together there.You can then pass this ID in your AJAX request just fine.