Welcome to Geeklog, Anonymous Friday, November 29 2024 @ 12:35 pm EST

Geeklog Forums

Menu according to permissions


Status: offline

gonzo

Forum User
Newbie
Registered: 01/20/04
Posts: 1
I am a newbie to this and I would like to know if it is possible to display a set of elements in the menu for one group of people (e.g. people not logged in) and another for members.

For example, I do not wish people to have access to site statistics, yet it shows up in the menu and people can click on it. I would like to avoid that. Same thing for "contribute" which should be visible only to people who have already logged in.

Many thanks
 Quote

Status: offline

exaurdon

Forum User
Regular Poster
Registered: 08/13/03
Posts: 107
Someone correct me if I am wrong, but I think the simple answer is, no, this isn't a built-in capability. You can very easily disable those features in the config.php file for non-logged in users, but often that 'menu' is hard coded into the template.

Now, having said that, I believe you could fairly easily create a theme that hid parts of the menu depending on if the user was logged in. Ihaven't done a lot of work with themes, but I believe you _can_ put php into template files, and if so, you could add code to the theme file to change the theme based ont eh user's login status.

Anyone else with a little more confidence in their answer?

Exaurdon
 Quote

Status: offline

Turias

Forum User
Full Member
Registered: 10/20/03
Posts: 807
Yeah, you should be able to do this with php.

Use the following pseudocode:

Text Formatted Code
if ($_USER['uid'] > 1)
{
   // Output menu for logged in users
}
else
{
   // Output menu for anonymous users
}
 
 Quote

gonzo

Anonymous
So..should I do that

1) in the header.thtml or
2) should I look into lib-common.php (where menu_elements is constructed) ?
 Quote

gonzo

Anonymous
Is it reasonable to build

{visitor_menu_elements} and {member_menu_elements} in lib-common.php?
 Quote

gonzo

Anonymous
Or rather

place the code suggested above into lib-common.php, with menu_elements being constructed differently depending on the status of $_USER['uid'] ?
 Quote

gonzo

Anonymous
Or rather

place the code suggested above into lib-common.php, with menu_elements being constructed differently depending on the status of $_USER['uid'] ?
 Quote

Status: offline

Turias

Forum User
Full Member
Registered: 10/20/03
Posts: 807
You can either put the code I posted in header.thtml or make your own variable in lib-common.php.

I would suggest doing it my way as it would not require changing lib-common.
 Quote

All times are EST. The time is now 12:35 pm.

  • Normal Topic
  • Sticky Topic
  • Locked Topic
  • New Post
  • Sticky Topic W/ New Post
  • Locked Topic W/ New Post
  •  View Anonymous Posts
  •  Able to post
  •  Filtered HTML Allowed
  •  Censored Content