Fork me on GitHub
Current release is 2.1.6 (21 Nov 2014).

Users who have not yet upgraded to 2.1 should get security release 2.0.18.14 (1 Nov 2014). We will stop providing these security releases to 2.0 at the end of this year.

[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 Help

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. :)

    vrijvlinder
  • peregrineperegrine ☯ hasta luego :) In-Flight MVP

    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);
    

    Monetary Donations will be appreciated if you use my plugins. Thanks in Advance.
    As a waiter gets a tip for a good meal, tips for successful solutions appreciated as well. click here for Peregrine | click here for FAQ

  • 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 ☯ hasta luego :) In-Flight 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

    Monetary Donations will be appreciated if you use my plugins. Thanks in Advance.
    As a waiter gets a tip for a good meal, tips for successful solutions appreciated as well. click here for Peregrine | click here for FAQ

Sign In or Register to comment.