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.
Can't manipulate Menu via plugin
Linc
Admin
In default.master.php:
$this->Menu->AddLink('Activity', T('Activity'), '/activity');In Vanilla's class.hooks.php (abbreviated):
public function Base_Render_Before(&$Sender) {In my plugin (after accounting for this bug):
$Sender->Menu->AddLink(T('Discussions'), T('Discussions'), '/discussions', FALSE);
}
public function Base_Render_Before(&$Sender) {...does nothing, but it DOES work for 'Discussions'. Printing the Menu array reveals it only has 'Discussions' in it when Base_Render_Before fires. Why is that? How can I manipulate those elements pre-render if they're called in the View itself?
$Sender->Menu->RemoveLinks('Activity');
}
0
Comments
Vanilla Forums COO [GitHub, Twitter, About.me]
We realized that in Vanilla 1 we had gone this way (allowing people to add to the main menu programmatically), and very rarely did people ever do it.
The themer-vs-plugin-developer war has officially begun.
With it halfway like this the themers still have to figure out the functions and the developers are crippled - half the menu functions don't work as expected.
If the menu build is in the view, what to do becomes more obvious to the themer but doesn't actually help him do it easier. Meanwhile the developer has lost all ability to use the menu building functions.
If the only thing being gained by the move to View was obviousness, couldn't the same be accomplished with a comment in the default.master template (as above)?
:ninja:
Yo. So since you brought up the subject of bribery (the magic words), we discussed how to solve this problem.
Currently the default master consists of a bunch of Menu->Addlink calls, followed immediately by a call to Menu->ToString. This leaves no way for plugins to modify menu contents or sort order. Internal to ToString() is a sorting function which looks at Garden.Menu.Sort (defined in config-defaults) and sorts the menu based on that.
We were thinking that changes could be made to the Menu module so that inside ToString there could be a FireEvent which could optionally provide a new sorting order array, as well as adding new menu items.
What do you think?
Vanilla Forums COO [GitHub, Twitter, About.me]
I still think it's oddly inconsistent though - now you'll be able to ADD to the nav menu with Base_Render_Before but only remove/sort SOME of them, whereas using the special hook instead will let you do all of it. You're gonna need a paragraph on the wiki just to explain the edge case you're creating.
Vanilla Forums COO [GitHub, Twitter, About.me]
It fixes what I need fixed. It just feels hacky.
If it's a fired event or nothing, add the FireEvent pls.
Vanilla Forums COO [GitHub, Twitter, About.me]
But does @Mark know you just called his magical methods kludgy?? :-o
Vanilla Forums COO [GitHub, Twitter, About.me]