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]

edited August 2009 in Vanilla 2.0 - 2.8
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:

$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


Comments

  • Great tip. Thanks. Looking forward to seeing your app.
  • Thanks very much, yeah just linking everything. The activity part of garden needs a rewrite to be more flexible as mark said, more like facebook's system. There also appears to be a problem with the new merged master on github which i hope will be shortly resolved. Had to go back to an older one.
  • ToddTodd Chief Product Officer Vanilla Staff
    What problem were you having with the master?
  • After installation (had to create the uploads folder as already reported) then it would redirect me to the settings page where it would remain blank as a white page. I have now gone back to an older version so i can carry out work on my plugin.
  • ToddTodd Chief Product Officer Vanilla Staff
    Ah. That is a bug that crept up in a number of situations where we were ajaxing in some xhtml that had script coming in which would cause the "white screen of death."

    Sorry about that. We'll iron these glitches in short order. Looking forward to your plugin.
  • No problem, i thought it would only be a temporary bug. Just getting all the bits in the right place.
    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.
  • ToddTodd Chief Product Officer Vanilla Staff
    I assume you mean right before:

    $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.
  • Sorry, about the line number, (old version) but yes that is where i mean.

    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.
  • ToddTodd Chief Product Officer Vanilla Staff
    edited August 2009
    I think we will give some guidance, but I'll have to do a walk through myself and write down the steps. To tell you the truth, I'm somewhat new to git myself having just started with it when Vanilla moved there earlier this summer. It can be very puzzling coming from other source control, but now that I've used it I double plus love it.

    I'll see what I can get going with a tutorial this weekend, but just for my info a few questions:
    1. What os/dev environment are you on?
    2. Did you download the code to work on it or git clone it?
    3. Are you just adding to the plugin directory with your own stuff or are you adding other stuff?
  • I'm on mac os x leopard.
    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.
Sign In or Register to comment.