Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Try Vanilla Forums Cloud product

Ready to contribute?

Amazing! Sign our contributors' agreement and then join us on GitHub.

Please upgrade to 2.1.x here. The 2.0 branch is no longer being updated.
Current version is 2.1.11, released 12 June.

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


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

  • 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

Sign In or Register to comment.