Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

[Solved(?)] [Documentation] How do I add a new Profile Tab at the beginning of the tab list?

businessdadbusinessdad Stealth contributor MVP
edited June 2012 in Vanilla 2.0 - 2.8

Hi all,
I'm trying to add a Profile Tab in User's Profile Page, and, so far, I managed to do it with ProfileController->AddProfileTab() method. However, this adds my tab after all the other ones, when I'd like to have it as the first (and default) one. What's the easiest way to achieve this?

As usual, thanks in advance for the help. :)

Answers

  • businessdadbusinessdad Stealth contributor MVP

    I found a working answer to my own questions, although it's not optimal. To decide in which orders to render the Tabs in User Profile, Vanilla uses a Sort Order (file tab.php).

    This Sort Order can come from two places:
    - User Preferences. Specifically, it's taken from $this->User->Preferences. The curious thing is that I haven't found any reference to this parameter anywhere in the whole code of Vanilla, therefore I must assume that the feature doesn't exist yet (unless it's delegated to an Addon, of which I ignore the existence).
    - Application Preferences, i.e. from configuration setting Garden.ProfileTabOrder. Not surprisingly, this setting is also not mentioned anywhere else in the code, therefore I make the same assumption as above.

    The solution
    Since there's no interface to change any of the above, I opted for the Application Configuration way. I added the following row in the configuration file:
    $Configuration['Garden']['ProfileTabOrder'] = array('MyTab', 'Discussions', 'Thanks', 'Comments', 'Votes');

    Magically, the Tabs appear in the order I specify. Users can't change it as there isn't a way for them to do it, but I think I can live with it, at least for now. :)

  • nice find and fix.

    user->preferences - it may be used in these places user->preferences

    applications/dashboard/controllers/class.notificationscontroller.php://         $PrefData = Gdn_Format::Unserialize($User->Preferences);
    applications/dashboard/controllers/class.profilecontroller.php:     $UserPrefs = Gdn_Format::Unserialize($this->User->Preferences);
    applications/dashboard/models/class.activitymodel.php:            $Preferences = $User->Preferences;
    applications/dashboard/models/class.activitymodel.php:            $Preferences = Gdn_Format::Unserialize($User->Preferences);
    applications/dashboard/views/profile/tabs.php:$SortOrder = ArrayValue('ProfileTabOrder', $this->User->Preferences, FALSE);
    library/core/class.session.php:            $this->_Preferences = Gdn_Format::Unserialize($this->User->Preferences);
    

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • businessdadbusinessdad Stealth contributor MVP

    @peregrine Apologies for the confusion, when I stated "I haven't found any reference to this parameter anywhere", in relation to $User->Preferences, I meant that I couldn't find any place where this parameter is set. As you pointed out, it's used here and there, but Users, apparently, have no way to change it.

    Of course, it could be done via code, but I don't think it's a good thing to allow Users to "code their own profile". ;)

    Note: by the way, it would be nice if I could accept my own answer, since it's what I was looking for... I'll write a note on QnA plugin.

  • peregrineperegrine MVP
    edited June 2012

    businessdad said:

    Note: by the way, it would be nice if I could accept my own answer, since it's what I was looking for... I'll write a note on QnA plugin.

    this has been mentioned before - perhaps it will change.

    meanwhile just @underdog flag your message and ask him to mark it solved :).

    and tag it with Documentation

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • To this: $Sender->AddProfileTab('Koppel Social Networks', '/profile/link');
    I want to add a "sprite" like this:

    Where would I add this ?

Sign In or Register to comment.