Please upgrade here. These earlier versions are no longer being updated and have security issues.

How do I make the MyProfile tab the default on profile views?

This discussion is related to the MyProfile addon.

I've tried a few custom routes, but can't quite crack it!

Comments

  • x00x00 MVP
    edited March 2014

    yeah doing it by routing is quite convoluted.

    The problem is you have to do a negative match becuase of user routing and other wildcard functionality

    read this whole thread

    http://vanillaforums.org/discussion/20427/set-default-profile-tab

    it does mean when you add profile plugins you may need to add to the route. It is just not a one time an forget thing in that case.

    grep is your friend.

    hgtonightUnderDogzayadur
  • Thank you, @x00!

  • beschizzabeschizza New
    edited March 2014

    I've given that as best a try I can, and no luck!

    The MyProfile plugin creates the extra tab (with the name MyProfile), but the routes I can think to default to it just don't work.

    With the Route Expression ^profile(/(?!activity|notifications|discussions)([0-9]/)?[^/]*?/?)$

    these targets all set the given default tab:

    profile/comments$1 to /profile/comments/1/username

    profile/discussions$1 to /profile/discussions/1/username

    profile/activity$1 to /profile/activity

    but profile/myprofile$1 just offers a blank page

    (Setting the target to profile/activity/1/username$1 works, though, but only with that particular hard-coded username)

  • x00x00 MVP
    edited March 2014

    sorry let me explain, you need to remove all profile routes you currently have

    Route Expression

    ^profile(/(?!activity|notifications|discussions|edit|password|invitations|myprofile)([0-9]/)?[^/]*?/?)$

    Target

    profile/myprofile$1

    Type

    Internal

    There are negative matches you are saying anything NOT activity|notifications|discussions|edit|password|invitations|myprofile

    needs to go to profile/myprofile

    the reason for the negative match is becuase you can't be sure if it is going to be a username or a method.

    the only other approach would be programmatic. If you are interested in such a solution PM me. It should offer more rational detection where can just set the default controller.

    grep is your friend.

    Shadowdare
  • beschizzabeschizza New
    edited March 2014

    I'm beat! Even with your help I can't get it working using routes. My guess is that I have messed something up somewhere else and am wasting your time.

    I was able to get it done by hacking class.profilecontroller.php to remove the usual default profile view loop, lines 321-328, with this:

    $HackedDispatch = '/profile/myprofile/'. $this->User->UserID . "/" . ConcatSep('/', rawurlencode($UserReference), rawurlencode($Username), rawurlencode($UserID));

    return Gdn::Dispatcher()->Dispatch($HackedDispatch);

    If this is particularly horrible, remind me to PM you :)

  • Yep it not really a good idea to modify the core. It will get overwritten.

    grep is your friend.

Sign In or Register to comment.