SergeiGrey Posted July 22, 2012 Share Posted July 22, 2012 Hi Guys I need some help please... I get the following error. Notice: Undefined index: layout in /home/wwwitsmf/public_html/components/com_jomdirectory/router.php on line 43 Notice: Undefined index: task in /home/wwwitsmf/public_html/components/com_jomdirectory/router.php on line 39 Here is the code: // we need a menu item. Either the one specified in the query, or the current active one if none specified if (empty($query['Itemid'])) { $menuItem = $menu->getItems('link','index.php?option=com_jomdirectory&view=homepage&layout=categories.tpl&id=',true); $query['Itemid'] = $menuItem->id; // print_r($menuItem); } line 39: if(isset($query['task']) & $query['task']!=='detailed') { if($query['task']=='search' ) { Line43: if($query['layout']!='latest.tpl' && $query['layout']!='categories.tpl') { $segments[] = 'category'; } } else { $segments[] = str_replace(' ', '-', $query['task']); } } unset($query['layout']); unset($query['task']); // if(isset($query['category'])) // { // $segments[] = str_replace(' ', '-', $query['category']); // unset($query['category']); // } Quote Link to comment https://forums.phpfreaks.com/topic/266095-undefined-index-task-in-undefined-index-layout-in/ Share on other sites More sharing options...
mikhl Posted July 22, 2012 Share Posted July 22, 2012 Please use the correct tags for displaying code. if(isset($query['task']) & $query['task']!=='detailed') should be if(isset($query['task']) && $query['task']!=='detailed') check that your array keys are being defined before being used Quote Link to comment https://forums.phpfreaks.com/topic/266095-undefined-index-task-in-undefined-index-layout-in/#findComment-1363581 Share on other sites More sharing options...
SergeiGrey Posted July 23, 2012 Author Share Posted July 23, 2012 Hi Thanks for the reply... sorry for not pasting the code in the correct tags... I am not really a programmer. I don't know how to fix the code because I didn't write it. It is a plugin that I bought for Joomla from Comdev and I have had no joy from the developer and I paid 200 Euro for the plugin. So any assistance in this regards will be highly appreciated. Regards Sergei Quote Link to comment https://forums.phpfreaks.com/topic/266095-undefined-index-task-in-undefined-index-layout-in/#findComment-1363618 Share on other sites More sharing options...
mikhl Posted July 23, 2012 Share Posted July 23, 2012 // we need a menu item. Either the one specified in the query, or the current active one if none specified if (empty($query['Itemid'])) { $menuItem = $menu->getItems('link','index.php?option=com_jomdirectory&view=homepage&layout=categories.tpl&id=',true); $query['Itemid'] = $menuItem->id; // print_r($menuItem); } line 39: if(isset($query['task']) & $query['task']!=='detailed') { if($query['task']=='search' ) { Line43: if($query['layout']!='latest.tpl' && $query['layout']!='categories.tpl') { $segments[] = 'category'; } } else { $segments[] = str_replace(' ', '-', $query['task']); } } unset($query['layout']); unset($query['task']); // if(isset($query['category'])) // { // $segments[] = str_replace(' ', '-', $query['category']); // unset($query['category']); // } Quote Link to comment https://forums.phpfreaks.com/topic/266095-undefined-index-task-in-undefined-index-layout-in/#findComment-1363622 Share on other sites More sharing options...
mikhl Posted July 23, 2012 Share Posted July 23, 2012 change if(isset($query['task']) & $query['task']!=='detailed') to if(isset($query['task']) && $query['task']!=='detailed') and if($query['layout']!='latest.tpl' && $query['layout']!='categories.tpl') { to if(isset($query['layout']) && $query['layout']!='latest.tpl' && $query['layout']!='categories.tpl') { Try the code I have given above and see what the results are. I leave no promises that this is going to fix the problem. The problem is that the keys in the array is not being defined and then is being used. You cannot use an array if you do not first define it. There must be somewhere in the script, a part that you have not posted here, where the array is initially created with the two keys that are creating the problem. Make sure they are being set propperly. Also ensure they will be set to a default value such as NULL even if they are to not be used. I recommend you look on google for some basic PHP tutorials before you making any more major changes to the script. However, I would recommend you be careful where you buy your scripts from. Quote Link to comment https://forums.phpfreaks.com/topic/266095-undefined-index-task-in-undefined-index-layout-in/#findComment-1363624 Share on other sites More sharing options...
SergeiGrey Posted July 23, 2012 Author Share Posted July 23, 2012 Thank you for all the help. I will test tonight and provide feedback... Quote Link to comment https://forums.phpfreaks.com/topic/266095-undefined-index-task-in-undefined-index-layout-in/#findComment-1363680 Share on other sites More sharing options...
SergeiGrey Posted July 24, 2012 Author Share Posted July 24, 2012 Whoooooweeee... Mikhl I can't thank you enough it worked like a charm. Thank you so much for your help I didn't know what I was going to say to the customer we are out in South Africa so 200 euros is a considerable amount of money if the you take the Rand to Euro exchange rate into consideration. Thank you... Thank you... Thank you.... Regards Sergei Quote Link to comment https://forums.phpfreaks.com/topic/266095-undefined-index-task-in-undefined-index-layout-in/#findComment-1363929 Share on other sites More sharing options...
mikhl Posted July 24, 2012 Share Posted July 24, 2012 Glad I could help. Make sure you test he app/website properly to ensure all of the functionality works correctly. Especially concerning this part of the code. Quote Link to comment https://forums.phpfreaks.com/topic/266095-undefined-index-task-in-undefined-index-layout-in/#findComment-1363992 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.