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.
Menu Position Code [advice]
Hey,
I am currently writing my first plugin (application actually) for Vanilla 2. Its a friends plugin for a buddies list, and other features.
Now i wanted to add a menu to the top. That's easy enough with this code:
So all is good with the world apart from the fact that its at the end after sign out, a bit of a problem for me.
So i track down the sorting to
and it is a list of menu positions almost. The default is:
I wanted to add my menu item before Conversations, so i'm sure that most people here would put together this code in a second
but though i'd share it anyways. In my plugin before adding the links, i have this:
I use the array_search so it will always be before Conversations although any fixed index may work better.
Was hunting around and was annoying why Conversations menu item was in the right place but mine wasn't.
So i hope this helps anyone who may end up in a similar position.
Gary Mardell
I am currently writing my first plugin (application actually) for Vanilla 2. Its a friends plugin for a buddies list, and other features.
Now i wanted to add a menu to the top. That's easy enough with this code:
$Sender->Menu->AddLink('Friends', Gdn::Translate('Friends'), '/friends', FALSE);
So all is good with the world apart from the fact that its at the end after sign out, a bit of a problem for me.
So i track down the sorting to
$Sender->Menu->Sort
and it is a list of menu positions almost. The default is:
array('Dashboard', 'Discussions', 'Activity', 'Conversations', 'User');
I wanted to add my menu item before Conversations, so i'm sure that most people here would put together this code in a second
but though i'd share it anyways. In my plugin before adding the links, i have this:
$Location = array_search("Conversations", $Sender->Menu->Sort);
array_splice($Sender->Menu->Sort, $Location, 0 , "Friends");
I use the array_search so it will always be before Conversations although any fixed index may work better.
Was hunting around and was annoying why Conversations menu item was in the right place but mine wasn't.
So i hope this helps anyone who may end up in a similar position.
Gary Mardell
0
Comments
Sorry about that. We'll iron these glitches in short order. Looking forward to your plugin.
Can you add
$this->EventArguments['SideMenu'] = &$SideMenu;
to line 489 in the profile.php controller in garden. If you would be so kind as to get it added to the master, i think its in issues but not sure if its been sorted yet, i need it for my plugin.
Cheers. I find reporting stuff on the forum easier than the issue tracker.
$this->FireEvent('AfterAddSideMenu');
It's a bit off from line 489 on my dev. I've put it in the dev branch which means it will go into master for the next update.
Also @Immersion, if you want to keep your stuff pushed to github we will take your patches if you ask us to and they check out. This might be easier for you as you can work on your own branch, but merge our changes with it every time you pull them until we make the required fixes. Git seriously rules this way and if you use github for your changes it's free because it's open source.
Okay, haven't really looked into git, need to learn it i think, heard a lot of good things. Seems quite complex, any chance of a quick tutorial (maybe for the documentation) would be very helpful.
Thanks for adding it.
I'll see what I can get going with a tutorial this weekend, but just for my info a few questions:
I downloaded it with the "hardcore archiving" action.
I'm currently just writing an application, so separate from the actual framework. But i can imagine i will soon need to use some of my own events.