0
Welcome Guest! Login
0 items Join Now

Menu Title Changes For Registered Users

  • Menu Title Changes For Registered Users

    Posted 15 years 9 months ago
    • Hi,

      I'm new to Joomla, but have been getting familiar with the basics over the past few days. One trouble spot I am having is trying to change the name of one of my menu items when a user is logged in. I'm using the Simplex theme. Here are the details:

      When a user is not logged in the menu should be:
      Home | Medical Information | Premium Medical Service | Contact

      When a user is logged in, it should be:
      Home | Medical Information | Member Forums | Talk to the Dr. | Account Information | Contact

      There is probably a very simple solution, so I apologize for the beginners question. Here is what I attempted...

      I made two menus, one was mainmenu (the default) and the other was usermenu. The main menu was the first menu above, all public. The user menu was the second menu, all private. I then put both modules in the same position. In index.php of the template, I tried to modify the following code:

      Before:
       
       
      $menu_name        = $this->params->get("menuName", "mainmenu");
       

      After (I modified):
       
      if ($user->guest) {
          $menu_name        = $this->params->get("menuName", "mainmenu");
      } else {
          $menu_name        = $this->params->get("menuName", "usermenu");
      }
       

      This didn't work. Instead, some of the links had a confused security. The home link did not ask me to login, but the Medical Information, Premium Medical Service, and Contact links did ask me to login. When I logged in, there was no difference in the menu.

      Any help would be greatly appreciated.

      Best,
      Jason
  • Re: Menu Title Changes For Registered Users

    Posted 15 years 9 months ago
    • SimonJ621 wrote:
      When a user is not logged in the menu should be:
      Home | Medical Information | Premium Medical Service | Contact

      When a user is logged in, it should be:
      Home | Medical Information | Member Forums | Talk to the Dr. | Account Information | Contact

      I made two menus, one was mainmenu (the default) and the other was usermenu. The main menu was the first menu above, all public. The user menu was the second menu, all private. I then put both modules in the same position. In index.php of the template, I tried to modify the following code:

      You only need one "mainmenu."
      In the menu mark the links you want everyone to see as public.
      Mark the links for registered users as registered.
      Mark the links for an additional user (yourself, staff, etc.) as special.

      The user will be able to see the menu as assigned according to the level you have set for each user.

      To test this set up users for each, then login as each user and preview.

      An alternative is to have a mainmenu that everyone sees.
      And an additional menu left or right that only registered users see on the specified pages you assign them to.

      Good luck, hope this helps.
    • Mark your threads as Solved. Please, Please, Please!
      Using FIREBUG will save you time and HELP you learn.
      Tips Tricks and Tutorial Links
      Security Tips and Joomla Version Info
      Style Tips and Code Snippets
  • Re: Menu Title Changes For Registered Users

    Posted 15 years 9 months ago
    • Thanks for the quick reply. The reason for me creating 2 menus is because one of the menu items that is seen by a user not logged in needs to change or disappear when a user is logged in. The traditional way of showing additional content when a user is logged in works partly, but I also need to alter or remove a menu item when a user is logged in.

      I hope I'm explaining this well.

      Thanks!
    • Ben Lee's Avatar
    • Ben Lee
    • Elite Rocketeer
    • Posts: 4193
    • Thanks: 42

    Re: Menu Title Changes For Registered Users

    Posted 15 years 9 months ago
  • Re: Menu Title Changes For Registered Users

    Posted 15 years 9 months ago
    • Thanks for the links. I'll dig into them today and see if I can come up with a good solution. I'll keep you posted.
  • Re: Menu Title Changes For Registered Users

    Posted 15 years 9 months ago
    • @Ben

      Your tips and tricks post is great. That is going to keep me busy for hours :)

      The first link you sent mentioned this:
      Well, come to realize, hey... in RT, the menu's don't even need modules. So I removed the mainmenu and guestmenu modules but left the menu's themselves intact.

      Is this how all RT templates work?
    • Ben Lee's Avatar
    • Ben Lee
    • Elite Rocketeer
    • Posts: 4193
    • Thanks: 42

    Re: Menu Title Changes For Registered Users

    Posted 15 years 9 months ago
    • I wouldn't say that it works this way for ALL rockettheme templates, but for a good number of them. I also wouldn't say to delete any menu modules that you are using either. You want to keep the menu modules there, but you can unpublish them. The position that the main menu is displayed in pulls the menu info for the menu you define...by default, mainmenu.
  • Re: Menu Title Changes For Registered Users

    Posted 15 years 9 months ago
    • Thanks for all the information. I'll detail my solution:

      This solution allows for a menu to change (not just add new links) when a user is logged in.

      1. Copy the 'mainmenu' (this is the menu for the 'guest'), make the needed changes and name it 'membermenu' (this is the menu for the 'member').

      2. I disabled both modules for these menus (optional).

      3. I then made the following addition to index.php for the specific Template:

      Above the rt_styleloader.php include, put the following code:
       
          $user = & JFactory::getUser();
          if ($user->guest) {
              $menu_name="mainmenu";
          } else {
              $menu_name="membermenu";
          }
       

      To understand the details, this resource helped me immensely: link

      I am also thinking of using metamod instead of the above solution ( link ). This extension seems very handy. Does anyone have experiences with it? pros? cons?

      Thanks again for all the help, without which I'd still be digging through documentation trying to find a solution.

      Best,
      Jason
    • Ben Lee's Avatar
    • Ben Lee
    • Elite Rocketeer
    • Posts: 4193
    • Thanks: 42

    Re: Menu Title Changes For Registered Users

    Posted 15 years 9 months ago

Time to create page: 0.068 seconds