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.
Options

Best way to rename "Discussions" menu link to "Forums"?

edited February 2010 in Vanilla 2.0 - 2.8
I can think of one or two ways to do this, but I was wondering if anyone had any feedback or could suggest a commit to help fix this. While Garden's main menu structure is inside the default.master.php view which I've overridden in a template, unfortunately the "Discussions" link is not there. Instead, it's in vanilla/settings/hooks.php in the Base_Render_Before function. So while I can easily change it there, for the sake of making future upgrades easier (since Vanilla is still very cutting-edge), what other ways might I be able to change the Discussions link to say something else. It's kind of odd to put such text/translation in the hooks file, since it's really something that belongs better in a view file somewhere.

Any thoughts from others?

Comments

  • Options
    edited February 2010
    Here's how I've decided to handle this renaming issue, it's rather simple, since the output of the menu items is done in the view, I can just override the text in the menu array before writing it, in my default.master theme override:
    $this->Menu->Items['Discussions'][0]['Text'] = 'Forums';
    But it's not that simple-- there's a translation problem with vanilla's menu items in vanilla/settings/hooks.php. It translates the group name when it should be translating the menu text instead:
    ./applications/garden/modules/class.menumodule.php:      public function AddLink($Group, $Text, $Url, $Permission = FALSE, $Attributes = '', $AnchorAttributes = '')

    ./applications/garden/settings/hooks.php:
    $Menu->AddLink('Dashboard', Gdn::Translate('Dashboard'), 'garden/settings', 'Garden.Settings.Manage');
    $Menu->AddLink('Site Settings', Gdn::Translate('General'), 'garden/settings/configure', 'Garden.Settings.Manage');
    $Menu->AddLink('Site Settings', Gdn::Translate('Routes'), 'garden/routes', 'Garden.Routes.Manage');
    $Menu->AddLink('Site Settings', Gdn::Translate('Messages'), 'garden/message', 'Garden.Messages.Manage');
    $Menu->AddLink('Add-ons', Gdn::Translate('Applications'), 'garden/settings/applications', 'Garden.Applications.Manage');
    $Menu->AddLink('Add-ons', Gdn::Translate('Plugins'), 'garden/settings/plugins', 'Garden.Applications.Manage');
    $Menu->AddLink('Add-ons', Gdn::Translate('Themes'), 'garden/settings/themes', 'Garden.Themes.Manage');
    $Menu->AddLink('Users', Gdn::Translate('Users'), 'garden/user', array('Garden.Users.Add', 'Garden.Users.Edit', 'Garden.Users.Delete'));
    $Menu->AddLink('Users', Gdn::Translate('Roles & Permissions'), 'garden/role', 'Garden.Roles.Manage');
    $Menu->AddLink('Users', Gdn::Translate('Registration'), 'garden/settings/registration', 'Garden.Registration.Manage');
    $Menu->AddLink('Users', Gdn::Translate('Applicants'), 'garden/user/applicants', 'Garden.Applicants.Manage');

    ./applications/conversations/settings/hooks.php: $SideMenu->AddLink('Options', sprintf(Gdn::Translate('Send %s a Message'), $Sender->User->Name), '/messages/add/'.$Sender->User->Name);
    ./applications/conversations/settings/hooks.php: $Sender->Menu->AddLink('Conversations', $Inbox, '/messages/all', FALSE);
    ./applications/conversations/settings/hooks.php: $Sender->Menu->AddLink('Conversations', Gdn::Translate('New Conversation'), '/messages/add', FALSE);
    ./applications/vanilla/settings/hooks.php: $Sender->Menu->AddLink(Gdn::Translate('Discussions'), 'Discussions', $DiscussionsHome, FALSE);
    ./applications/vanilla/settings/hooks.php: $Sender->Menu->AddLink(Gdn::Translate('Discussions'), '\\'.$Bookmarked, '/discussions/bookmarked', FALSE, array('class' => 'MyBookmarks'));
    ./applications/vanilla/settings/hooks.php: $Sender->Menu->AddLink(Gdn::Translate('Discussions'), '\\'.$MyDiscussions, '/discussions/mine', FALSE, array('class' => 'MyDiscussions'));
    ./applications/vanilla/settings/hooks.php: $Sender->Menu->AddLink(Gdn::Translate('Discussions'), '\\'.$MyDrafts, '/drafts', FALSE, array('class' => 'MyDrafts'));
    ./applications/vanilla/settings/hooks.php: $Sender->Menu->AddLink(Gdn::Translate('Discussions'), 'New Discussion', '/post/discussion', FALSE);
    ./applications/vanilla/settings/hooks.php: $Menu->AddLink('Forum', Gdn::Translate('General'), 'vanilla/settings', 'Vanilla.Settings.Manage');
    ./applications/vanilla/settings/hooks.php: $Menu->AddLink('Forum', Gdn::Translate('Spam'), 'vanilla/settings/spam', 'Vanilla.Spam.Manage');
    ./applications/vanilla/settings/hooks.php: $Menu->AddLink('Forum', Gdn::Translate('Categories'), 'vanilla/settings/managecategories', 'Vanilla.Categories.Manage');
    ./plugins/CssThemes/class.cssthemes.plugin.php: $Menu->AddLink('Add-ons', 'Colors', 'plugin/cssthemes', 'Garden.Themes.Manage');
    So it looks as if for menus, you would first AddLink the top-level menu item, then AddLink with the same first group name the next sub-links, and the Text for each should be translated. Instead, Vanilla translates the group name used internally, which would mean to be technically correct, my line of code should translate the Discussions array name too.

    And, oddly enough, hooks.php doesn't translate Site Settings or Add-ons, making me wonder how their menus have such headings in the first place, though perhaps I've missed something. Also, cssthemes plugin doesn't translate Colors either. I have to wonder at seeing Translate so often. Why not translate within the Menu output instead?

    And Vanilla seems to use '\\' at the start of submenu names, but the rest don't, so ... is that for backwards-compatibility?
  • Options
    edited February 2010
    Made an issue 246 for this inconsistent AddLink behavior: http://github.com/lussumo/Garden/issues/issue/246
  • Options
    MarkMark Vanilla Staff
    edited February 2010
    Do you want to change the word "Discussions" to "Forums" across the entire application, or just in the menu? The language definitions make the assumption that you'd want it consistently renamed. The easiest way to accomplish this is to put a custom definition in your conf/locale.php file like this:
    <?php if (!defined('APPLICATION')) exit();
    $Definition['Discussions'] = 'Forums';</pre>

    Thanks for finding those inconsistencies with the menu module!
  • Options
    @Mark, really just the menu-- "Forums" is clearer there, describing the Categories view on a site which isn't just Vanilla.
Sign In or Register to comment.