[solved]Strange Behaviour with com_ajax and Menue Assignment

Did you find a bug in Joomla! 3.x but aren't sure? This forum is the place to help figure out if the problem is a bug and how to report it. If you are an experienced Joomla! user and are certain that you have found a bug please use the Bug Tracker to submit your issue.
This forum is for discussion about bugs and to get help with reporting them to the Bug Tracker: https://issues.joomla.org

Moderator: ooffick

Forum rules
Please use the official Bug Tracker to report a bug: https://issues.joomla.org
Locked
User avatar
zomtec
Joomla! Intern
Joomla! Intern
Posts: 78
Joined: Tue Jan 13, 2015 12:49 pm

[solved]Strange Behaviour with com_ajax and Menue Assignment

Post by zomtec » Sat Sep 05, 2015 1:03 pm

I have created a Module with some JavaScript and followed the Instructions on Using Joomla Ajax Interface.
A) Everything works fine, if i display the Module "On all Pages" within the Menue Assignment of the Module.
B) Everything works fine, if i display the Module "On all pages except those selected" within the Menue Assignment of the Module.

C) But if i choose "Only on the pages selected" the Module doesn't work correctly.

I played a little bit with the com_ajax and found out, that for the case C) the com_ajax doesn't find my module

Code: Select all

elseif ($input->get('module'))
{
	$module       = $input->get('module');
	$moduleObject = JModuleHelper::getModule('mod_' . $module, null);

	/*
	 * As JModuleHelper::isEnabled always returns true, we check
	 * for an id other than 0 to see if it is published.
	 */
	if ($moduleObject->id != 0)
	{


For Case C) $moduleObject->id is NULL and when i change the line
if ($moduleObject->id != 0)
to
if ($moduleObject->id == 0)
the Module works correctly

call of the com_ajax:
index.php?option=com_ajax&module=user_live_search&method=getUsers&format=json

Joomla-Version 3.4.3

Is there someone, who knows a solution or is this a bug?
Last edited by zomtec on Sun Sep 06, 2015 11:38 am, edited 1 time in total.

User avatar
zomtec
Joomla! Intern
Joomla! Intern
Posts: 78
Joined: Tue Jan 13, 2015 12:49 pm

Re: Strange Behaviour with com_ajax and Menue Assignment

Post by zomtec » Sun Sep 06, 2015 11:38 am

i guess i've found a solution.
it seems, that com_ajax cannot find the module on the active site, because of missing itemid of the active site.
i added

Code: Select all

$app =& JFactory::getApplication();
$menu       = $app->getMenu();
$active = $menu->getActive();
and enhanced the call of the com_ajax with the Itemid:
index.php?option=com_ajax&module=user_live_search&method=getUsers&format=json&Itemid=<?php echo $active->id; ?>

Now it works for all three cases A), B) and C)

the important use of itemid should be added at the documentation Using Joomla Ajax Interface

User avatar
masoesa
Joomla! Explorer
Joomla! Explorer
Posts: 300
Joined: Mon Sep 26, 2005 7:11 pm
Location: Brooklyn NY
Contact:

Re: [solved]Strange Behaviour with com_ajax and Menue Assign

Post by masoesa » Sun Jan 03, 2016 4:45 am

This is a big problem and everyone creating a mod should take this into account. It seems like non of my mods work if I select "Only on the ones selected".

So I have to use "Every one but the one selected". Now every time I create a menu item I have to go through all mods again. This is unmanageable.
http://going-natural.com
The site where Natural Beauty Shines


Locked

Return to “Joomla! 3.x Bug Reporting”