How to set the default tab in the profile page

Hi

Is there a way to set the default tab in the profile page (yoursite.com/profile) , right now activity is the default tab. I wish to do this in a plugin

Thanks

Comments

  • rloyolarloyola New
    edited November 2019

    I need this because we have custom content added as part of the profile page and profile tab and I want to have that tab selected as default when the profile page shows up. I was able to accomplish this by overriding the ProfileController Index in a plugin but I had a feeling its not a good thing. Does anyone knows how to do it the right way?

  • The most intuitive approach would be a rewrite rule but that wouldn't work. Profile routes look like that:

    • /profile
    • /profile/username
    • /profile/comments/username
    • /profile/comments

    So neither the first parameter after "/profile" nor the last parameter is always the username or the route. A rewrite rule therefore cannot be used 😐️


    The next approach I had thought about would have been hooking into the dispatcher or the controllers initialize method, but that didn't look like the best approach either.

    Therefore I think it is the best to do it that way:


       public function profileController_render_before($sender) {
           if ($sender->RequestMethod == 'index') {
               redirectTo(userUrl($sender->User, '', 'comments'));
           }
       }
    
  • Thanks

Sign In or Register to comment.