1
Daigoro
Show main menus sub menus based on userlevel. Possible?
  • 2004/3/13 16:20

  • Daigoro

  • Quite a regular

  • Posts: 223

  • Since: 2003/7/3 2


Is it possible to descide what sub-menues are visible to users of a site?

In other words, if a used don't have the right to access a sub-menu, then instead if saying so after the user has clicked on the sub-menu, I'd like to simply remove the sub menu for that user.

Thanks in advance,
Daigoro

2
JackJ
Re: Show main menus sub menus based on userlevel. Possible?
  • 2004/3/13 17:35

  • JackJ

  • Community Support Member

  • Posts: 747

  • Since: 2003/8/31


I dont think so, using some extra code you can specify which group to hide a sub-menu from, but not an individual user.

I have some code if you are interested in the groups idea

3
JackJ
Re: Show main menus sub menus based on userlevel. Possible?
  • 2004/3/13 17:53

  • JackJ

  • Community Support Member

  • Posts: 747

  • Since: 2003/8/31


For news, and to hide the submenu from groups, go to the xoops_version.php in the root of "News"

Look for the "menu" part and change it to something like this:

// Menu
$modversion['hasMain'] = 1;
global $xoopsUser;
if(!empty($xoopsUser)) {
$group = $xoopsUser->getGroups();
if (in_array(2, $group)) { //and other groups
$modversion['sub'][1]['name'] = _MI_NEWS_SMNAME1;
$modversion['sub'][1]['url'] = "submit.php";
}
}
$modversion['sub'][2]['name'] = _MI_NEWS_SMNAME2;
$modversion['sub'][2]['url'] = "archive.php";


group 1 is admins
group 2 is registered users

each group you create has its own id

this can be adapted to any module, just look for the xoops_version.php

I found this code from here and there, I am not a php genius..

4
simonvl
Re: Show main menus sub menus based on userlevel. Possible?
  • 2004/3/13 18:13

  • simonvl

  • Just popping in

  • Posts: 44

  • Since: 2004/1/28


Hi JackJ, similar question:
I have tried to use some code posted on this forum before (I think it was by you but not sure).

I have not had much success with it. I have tried using an adaptation of MultiMenu and also tried using the system New Block but it hasn't worked so far.

I would like to make a menu using groups to select whether to display some menu/submenu items and...

I would also like to display submenu items only when in the appropriate section of the site using PHP. Some modules e.g. news do this (Submit/archive) but I would like to create a custom menu with my own submenus.

I know you are always busy helping a hundred other people, but I hope you can still help us. If I get it working I would like to make a generic version available as a module with a home page and a menu block, I think quite a few people would like to use it.
And you wouldn't have to answer this question again!

Thanks in advance,
Simon

5
Daigoro
Re: Show main menus sub menus based on userlevel. Possible?
  • 2004/3/13 18:39

  • Daigoro

  • Quite a regular

  • Posts: 223

  • Since: 2003/7/3 2


Thanks for the answer.

It's not realy what I had hoped, as it requires editing (hacking) most of the modules with sub menus, but I understand why it's nessary.

However, it would be nice to see an addition to the group admin page, where each menu and submenu can be configgured for each group.

Regards.

6
JackJ
Re: Show main menus sub menus based on userlevel. Possible?
  • 2004/3/13 19:00

  • JackJ

  • Community Support Member

  • Posts: 747

  • Since: 2003/8/31


For a good breakdown of some of the issues or choices involved see this thread Here

Did you intend for this custom block to be part of an existing module?

I will get back to you on this, sorry I need to go just now..

Edit: this was for simonvl..

7
Daigoro
Re: Show main menus sub menus based on userlevel. Possible?
  • 2004/3/13 19:35

  • Daigoro

  • Quite a regular

  • Posts: 223

  • Since: 2003/7/3 2


I'll follow that thread later...

I'd like to be able to control the menu on a system level, instead of hacking each ane every module.
the admin->group preference page, allready does what I'd like, except that it's about controling what blocks are available for each group.
I'd like to also be able to control what menus and sub-menus are available for each group.

Regards.

8
Vargr
Re: Show main menus sub menus based on userlevel. Possible?
  • 2004/3/13 21:33

  • Vargr

  • Not too shy to talk

  • Posts: 130

  • Since: 2003/6/19


Hi JackJ

Used your code and changed it a bit, as all Daigoro and I need (for now anyway) is the possibility to prevent non-registered users to see some of the submenus, such as "Submit", as it is only registered users that are allowed to submit news.

Thus what we use from your code is now:

Quote:

// Menu
$modversion['hasMain'] = 1;
global $xoopsUser;
if(!empty($xoopsUser)) {
$group = $xoopsUser->getGroups();
if (in_array(2, $group)) { //and other groups
$modversion['sub'][1]['name'] = _MI_NEWS_SMNAME1;
$modversion['sub'][1]['url'] = "submit.php";
}
}
$modversion['sub'][2]['name'] = _MI_NEWS_SMNAME2;
$modversion['sub'][2]['url'] = "archive.php";


Thank you for your help!

9
JackJ
Re: Show main menus sub menus based on userlevel. Possible?
  • 2004/3/13 21:52

  • JackJ

  • Community Support Member

  • Posts: 747

  • Since: 2003/8/31


Vargr

no problem, but the above original "unchanged" code is designed to prevent non-registered users from seeing submit? Work for me anyway..

group 2 is registered users, to add other groups you just add another group id

regards

10
Vargr
Re: Show main menus sub menus based on userlevel. Possible?
  • 2004/3/13 21:58

  • Vargr

  • Not too shy to talk

  • Posts: 130

  • Since: 2003/6/19


Well, I couldn't make it work that way. Possibly I did something wrong. But I made it work for our - limited - need.

And I am not quit sure where to read the group-ID numbers. If you have more than the three default groups, how do you tll what ID each group has?

Login

Who's Online

214 user(s) are online (139 user(s) are browsing Support Forums)


Members: 0


Guests: 214


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Mar 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits