Hide menu-items in other menu-modules then the FUA menu-module
From FUA component version 3.0.4, you can hide menu-items also in other menu-modules then the FUA-menu-module. For this you need to alter the code of your menu-module to make it work with FUA. Here is how.
Your menu-module probably has a helper-file here:
/modules/mod_modulename/helper.php
look for the code that gets the menu-items from the database:
$rows = $items->getItems('menutype', $params->get('menutype'));
Change that line to:
$rows = $items->getItems('menutype', $params->get('menutype'));
//start filter menu items
$menu_type_to_filter = $params->get('menutype');// $params->get('menutype') or $this->getParam('menutype')
$path_to_root = '../../';// path to root of website. number of slashes is number of directories up
if(file_exists(dirname(__FILE__).DS.'/'.$path_to_root.'components/com_frontenduseraccess/menuaccess.php')){
require_once(dirname(__FILE__).DS.'/'.$path_to_root.'components/com_frontenduseraccess/menuaccess.php');
$frontenduseraccessMenuAccessChecker = new frontenduseraccessMenuAccessChecker();
$rows = $frontenduseraccessMenuAccessChecker->filter_menu_items($rows, $menu_type_to_filter);
}
//end filter menu items
Make sure:
- The path from the file this code is in, to the root of the site is correct.
In the above example (from mod_roknavmenu) the file needs to go 2 directories up to get to the root of the site. In your site, find the directory this code is in, then count how many directories up the script has to go to reach the root of the site. For each directory up you make a '../' in the variable $path_to_root. - The menu-type to filter is parsed in the same way as in the original code.
In your menu-modules configuration you set the module to load a specific menu. The code that gets the menu-items from your database needs to know from which menu-type to get the items. In the above example, that menu-type is parse as $params->get('menutype'). In some menu's this menu-type might be parsed as $this->getParam('menutype'), so make sure the menu-type is parsed in the same way to variable $menu_type_to_filter as in the original code that gets the menu-items from the database. In the above example: $rows = $items->getItems('menutype', $params->get('menutype'));.
In case your menu is not a module, but is integrated in a 3rd party template, the above code can also be used, but the 2 variables have to be altered. For example in the ja_kyanite_ii template from Joomlart the code to change is in
/templates/ja_kyanite_ii/libs/menu/base.class.php
line 51
$rows = $items->getItems('menutype', $this->getParam('menutype'));
which needs to be changed to
$rows = $items->getItems('menutype', $this->getParam('menutype'));
//start filter menu items
$menu_type_to_filter = $this->getParam('menutype');// $params->get('menutype') or $this->getParam('menutype')
$path_to_root = '../../../../';// path to root of website. number of slashes is number of directories up
if(file_exists(dirname(__FILE__).DS.'/'.$path_to_root.'components/com_frontenduseraccess/menuaccess.php')){
require_once(dirname(__FILE__).DS.'/'.$path_to_root.'components/com_frontenduseraccess/menuaccess.php');
$frontenduseraccessMenuAccessChecker = new frontenduseraccessMenuAccessChecker();
$rows = $frontenduseraccessMenuAccessChecker->filter_menu_items($rows, $menu_type_to_filter);
}
//end filter menu items
As you see this file needs to go 4 directories up to get to the root of the site, and parses the menu-type using $this.
We can not provide downloads of installable template or menu's which have already been fixed. This is because of legal reasons. Thats why we provide these codes so you can alter the menu yourself. We regret we can not make this any easyer for you.
If you can't work this out, please contact us using the contact form.
Superfish Menu
The superfish module uses Joomla's mod_mainmenu helper.php file to load the menu-items. So you have to alter the code so it uses the FUA-menu-module instead.
In file /modules/mod_superfishmenu/helper.php
require_once JPATH_BASE.DS.'modules'.DS.'mod_mainmenu'.DS.'helper.php';
class modSuperfishMenuHelper extends modMainMenuHelper {
function render(&$params, $callback) {
// Include the new menu class
$xml = modMainMenuHelper::getXML($params->get('menutype'), $params, $callback);
change to:
//require_once JPATH_BASE.DS.'modules'.DS.'mod_mainmenu'.DS.'helper.php';
require_once JPATH_BASE.DS.'modules'.DS.'mod_frontenduseraccessmenu'.DS.'helper.php';
//class modSuperfishMenuHelper extends modMainMenuHelper {
class modSuperfishMenuHelper extends modFrontendUserAccessMenuHelper {
function render(&$params, $callback) {
// Include the new menu class
//$xml = modMainMenuHelper::getXML($params->get('menutype'), $params,
$callback);
$xml = modFrontendUserAccessMenuHelper::getXML($params->get('menutype'), $params, $callback);
YOOtheme templates
The menu's in Yootheme templates use a template override on Joomla's mod_mainmenu. You have to alter the override to make it get the menu-items from the FUA-menu-module instead of the main-menu-module. This is how:
file: /templates/yoo_template_name/html/mod_mainmenu/yoomenu.php
find this line:
$suffix = $params->get('class_sfx');
change to:
$suffix = $params->get('class_sfx');
require_once JPATH_BASE.DS.'modules'.DS.'mod_frontenduseraccessmenu'.DS.'helper.php';
AND
find this line:
$xml = modMainMenuHelper::getXML($params->get('menutype'), $params, 'YOOMenu'.ucfirst($menu).'Decorator');
change to:
//$xml = modMainMenuHelper::getXML($params->get('menutype'), $params, 'YOOMenu'.ucfirst($menu).'Decorator');
$xml = modFrontendUserAccessMenuHelper::getXML($params->get('menutype'), $params, 'YOOMenu'.ucfirst($menu).'Decorator');
AND
find this line:
modMainMenuHelper::render($params, $callback);
change to:
//modMainMenuHelper::render($params, $callback);
modFrontendUserAccessMenuHelper::render($params, $callback);
If you want to use the Yootheme menu styles (accordion etc.) you need to add this module override to your Yootheme template. Download, unzip and paste the folder mod_frontenduseraccessmenu into /templates/yoo_explorer/html/
Joomlart
Only needed if your template has its own menu. Some templates render their menu from mod_mainmenu. So we have to tell the template to get the data from the FUA menu-module instead.
This example is from the ja_kyanite_ii template.
file: /templates/template_name/libs/menu/base.class.php
line 51
$rows = $items->getItems('menutype', $this->getParam('menutype'));
change to
$rows = $items->getItems('menutype', $this->getParam('menutype'));
//start filter menu items
$menu_type_to_filter = $this->getParam('menutype');// $params->get('menutype') or $this->getParam('menutype')
$path_to_root = '../../../../';// path to root of website. number of slashes is number of directories up if(file_exists(dirname(__FILE__).DS.'/'.$path_to_root.'components/com_frontenduseraccess/menuaccess.php')){
require_once(dirname(__FILE__).DS.'/'.$path_to_root.'components/com_frontenduseraccess/menuaccess.php');
$frontenduseraccessMenuAccessChecker = new frontenduseraccessMenuAccessChecker();
$rows = $frontenduseraccessMenuAccessChecker->filter_menu_items($rows, $menu_type_to_filter);
}
//end filter menu items
JoomlaJunkie
JoomlaJunkie uses its own (suckerfish) menu. This example is from Ario, but might also work on other templates by them.
file: /templates/template_name/jj_suckerfish.php
find this code:
$rows = $sql->loadObjectList( 'id' );
replace by:
$rows = $sql->loadObjectList( 'id' );
//start filter menu items
$menu_type_to_filter = $menu_name;// $params->get('menutype') or $this->getParam('menutype')
$path_to_root = '../../';// path to root of website. number of slashes is number of directories up
if(file_exists(dirname(__FILE__).DS.'/'.$path_to_root.'components/com_frontenduseraccess/menuaccess.php')){
require_once(dirname(__FILE__).DS.'/'.$path_to_root.'components/com_frontenduseraccess/menuaccess.php');
$frontenduseraccessMenuAccessChecker = new frontenduseraccessMenuAccessChecker();
$rows = $frontenduseraccessMenuAccessChecker->filter_menu_items($rows, $menu_type_to_filter);
}
//end filter menu items
Shape5 Suckerfish
This comes from the Touch-of-Soul template.
file: /templates/template_name/s5_suckerfish.php
find this code:
$rows = $database->loadObjectList( 'id' );
echo $database->getErrorMsg();
$sql = "SELECT m.* FROM #__menu AS m"
. "\nWHERE menutype='". $menutype ."' AND m.published='1'";
$database->setQuery( $sql );
$subrows = $database->loadObjectList( 'id' );
replace by:
$rows = $database->loadObjectList( 'id' );
//start filter menu items
$menu_type_to_filter = $menutype;// $params->get('menutype') or $this->getParam('menutype')
$path_to_root = '../../';// path to root of website. number of slashes is number of directories up
if(file_exists(dirname(__FILE__).DS.'/'.$path_to_root.'components/com_frontenduseraccess/menuaccess.php')){
require_once(dirname(__FILE__).DS.'/'.$path_to_root.'components/com_frontenduseraccess/menuaccess.php');
$frontenduseraccessMenuAccessChecker = new frontenduseraccessMenuAccessChecker();
$rows = $frontenduseraccessMenuAccessChecker->filter_menu_items($rows, $menu_type_to_filter);
}
//end filter menu items
echo $database->getErrorMsg();
$sql = "SELECT m.* FROM #__menu AS m"
. "\nWHERE menutype='". $menutype ."' AND m.published='1'";
$database->setQuery( $sql );
$subrows = $database->loadObjectList( 'id' );
//start filter menu items
$menu_type_to_filter = $menutype;// $params->get('menutype') or $this->getParam('menutype')
$path_to_root = '../../';// path to root of website. number of slashes is number of directories up
if(file_exists(dirname(__FILE__).DS.'/'.$path_to_root.'components/com_frontenduseraccess/menuaccess.php')){
require_once(dirname(__FILE__).DS.'/'.$path_to_root.'components/com_frontenduseraccess/menuaccess.php');
$frontenduseraccessMenuAccessChecker = new frontenduseraccessMenuAccessChecker();
$subrows = $frontenduseraccessMenuAccessChecker->filter_menu_items($subrows, $menu_type_to_filter);
}
//end filter menu items
Shape5 accordion menu
Alter the modules helper file to use FUA restrictions as described at the top of this page.
file: /modules/mod_s5_accordion_menu/helper.php
Rockettheme
Rockettheme comes with its own menu-module. The menu-module does often not have to be published in the module manager, the template simply uses the menu-modules code in the background. So althou the menu-module is not published, it is used.
To make the menu-module work with FUA alter the code as described at the top of this page using this file:
/modules/mod_roknavmenu/helper.php
on line 32 you will see this code:
$rows = $items->getItems('menutype', $params->get('menutype'));
change this to:
// Get Menu Items
$rows = $items->getItems('menutype', $params->get('menutype'));
//start filter menu items
$menu_type_to_filter = $params->get('menutype');// $params->get('menutype') or $this->getParam('menutype')
$path_to_root = '../../';// path to root of website. number of slashes is number of directories up
if(file_exists(dirname(__FILE__).DS.'/'.$path_to_root.'components/com_frontenduseraccess/menuaccess.php')){
require_once(dirname(__FILE__).DS.'/'.$path_to_root.'components/com_frontenduseraccess/menuaccess.php');
$frontenduseraccessMenuAccessChecker = new frontenduseraccessMenuAccessChecker();
$rows = $frontenduseraccessMenuAccessChecker->filter_menu_items($rows, $menu_type_to_filter);
}
//end filter menu items
Exmenu
Exmenu is a fantastic menu-module, with many templating possibilities.
version: 1.0.6
file: /modules/mod_exmenu-j15/exmenu/loader/menu.menuloader.class.php
line: 152
$orphanedIds = array();
replace with:
$orphanedIds = array();
//start filter menu items
$menu_type_to_filter = $menutype;// $params->get('menutype') or $this->getParam('menutype')
$path_to_root = '../../../../';// path to root of website. number of slashes is number of directories up
if(file_exists(dirname(__FILE__).DS.'/'.$path_to_root.'components/com_frontenduseraccess/menuaccess.php')){
require_once(dirname(__FILE__).DS.'/'.$path_to_root.'components/com_frontenduseraccess/menuaccess.php');
$frontenduseraccessMenuAccessChecker = new frontenduseraccessMenuAccessChecker();
$rows = $frontenduseraccessMenuAccessChecker->filter_menu_items($rows, $menu_type_to_filter);
}
//end filter menu items
swMenuPro
file:modules/mod_swmenupro/functions.php
line:
57
return $final_menu;
change to:
$menu_type_to_filter = $menu;
$rows = array();
if(file_exists(JPATH_ROOT.DS.'components/com_frontenduseraccess/menuaccess.php')){
require_once(JPATH_ROOT.DS.'components/com_frontenduseraccess/menuaccess.php');
$frontenduseraccessMenuAccessChecker = new frontenduseraccessMenuAccessChecker();
$menu_items_with_access = $frontenduseraccessMenuAccessChecker->filter_menu_items($rows, $menu_type_to_filter);
$menu_items_with_access_array = array();
foreach($menu_items_with_access as $menu_item){
$menu_items_with_access_array[] = $menu_item->id;
}
$temp = array();
foreach($final_menu as $final_menu_item){
if(in_array($final_menu_item['ID'], $menu_items_with_access_array)){
$temp[] = $final_menu_item;
}
}
$final_menu = $temp;
}
return $final_menu;