A small trick with a View
After you register and login to the site the user becomes available “offline.” This menu, in addition to links to edit user settings and logout of work still contains 2 items: “Add news” and “Add Reference”. However, after registering, users are a group of Registered, which does not have the right to add news, so the availability of these options in the user menu for regular users creates additional confusion. You can certainly remove these items, but then they will not be available for other user groups. In this article I will discuss how to solve this little problem.
To solve this problem, we are in the site template to add additional area to publish a module that will be displayed only to users of Registered. Then make a copy of a custom menu from which exclude the items “Add news” and “Add Reference” and publish the module in the newly created area.
Template modification
Suppose the user menu is published in the field left the current template. Needs to be done so that the area left was visible to all registered users except for group Registered, but some extra space (we call it registeredusersmenu) Was visible only to users of Registered. How to do it? It is very simple.
Is in the file index.php of your template code modules are loaded area left:
<? Php mosLoadModules ( 'Left' ); ?>
and replace this code with the following:
<? Php
if ($ My->usertype == 'Registered') {
mosLoadModules ( 'Registeredusersmenu' );
} else {
mosLoadModules ( 'Left' );
}
?>
How will it work? If the current user belongs to a group Registered, It will load the modules from the registeredusersmenu Otherwise, download the modules published in the field left.
Note: if in the area left were published by some other modules, they will not be displayed to the user group Registered. Therefore it is more correct to create another area in the pattern, say usermenu. And to publish menu of the default user in this area.
Then download code modules will look like this:
<? Php
if ($ My->usertype == 'Registered') {
mosLoadModules ( 'Registeredusersmenu' );
} else {
mosLoadModules ( 'Usermenu' );
}
?>
Create and configure menus registeredusermenu
- Avtorizuemsya in adimnistrativnoy panel Joomla
- Create a sub-menu (let’s call it registeredusermenu)
- Create a registeredusermenu items “My Account” and “Exit”
- Select the menu item Modules-> Site Modules
- In the list of modules of the website select our new menu and press Edit
- Set access level Public
- Sets the publication registeredusersmenu
- Push the button Save
