What's JRequest::setVar('hidemainmenu', 1)
Question
I have been using joomla for a while now. I come across JRequest::setVar('hidemainmenu', 1)
everyday but I couldn't figure out what it is. Even though I comment that line nothing changes. What I want to know is does my code require JRequest::setVar('hidemainmenu', 1)
? Is it a standard to import that line ? Thanks
Solution
JRequest::setVar('hidemainmenu', 1)
is used when we want to disable main menu in Joomla admin. It is generally used in Editing sections of our component. It prevents users from leaving unsaved records open. Since user will not be able to use Joomla menu options at that time so the only option remains is component specific toolbar.
For example when you are viewing Userlist in Joomla admin user manager, you can access he main admin menu options but when you are editing a specific user , joomla admin menu is disabled.
This feature can be achieved by using JRequest::setVar('hidemainmenu', 1)
OTHER TIPS
This is especially useful with views for which, when a user navigates away without following the correct procedure, an item becomes locked.
If we modify the hidemainmenu request value to 1, the submenu will not be displayed. We normally do this in methods in our controllers; a common method
in which this would be done is edit()
. This example demonstrates how:
JRequest::setVar('hidemainmenu', 1);
There is one other caveat when doing this; the main menu will be deactivated. This screenshot depicts the main menu across the top of backend:
This screenshot depicts the main menu across the top of backend when hidemainmenu is enabled; you will notice that all of the menu items are grayed out:
JRequest
will be deprecated. In 2.5+ versions use
$app = JFactory::getApplication();
$input = $app->input;
$input->set('hidemainmenu', 1);