1

I am hooking in to cp_menu_array - which seems light on the old documentation - to stick up a menu for my module.

All works as expected, except the language strings.

public function cp_menu($menu)
{
    if ($this->ee->extensions->last_call !== false) {
        $menu = $this->ee->extensions->last_call;
    }       

    $menu['giftcards'] = array();
    $menu['giftcards']['view_giftcards'] = BASE.'&C=addons_modules&M=show_module_cp&module=store_giftcard';
    $menu['giftcards']['edit_giftcard_emails'] = BASE.'&C=addons_modules&M=show_module_cp&module=store_giftcard';

    return $menu;
}

This gives me the required menu item, but the strings pop up as 'nav_giftcards', etc. So, one might expect to stick them in the lang array thus:

$lang = array(
    "store_giftcard_module_name" => 'Store Giftcard',
    "store_giftcard_module_description" => 'Gift certificate functionality     for Expresso Store',
    "nav_giftcards" => 'Giftcards',
    "nav_view_giftcards" => 'View Giftcards',
    "nav_edit_giftcard_emails" => 'View Giftcards'
);

Alas, to no avail.

If anyone can point out the trick I'm probably missing before I need to dive in and walk through the core to find out, I'd be much obliged.

1

You can try to add next lines into your cp_menu_array code in case if you need to have some dynamic code:

ee()->lang->language['nav_giftcards'] = 'Giftcards';
ee()->lang->language['nav_view_giftcards'] = 'View Giftcards';
ee()->lang->language['nav_edit_giftcard_emails'] = 'View Giftcardss';

Or load your file with lang array:

ee()->lang->loadfile($module_name);
1
  • Thanks for that Max - both suggestions work, though the first negates internationalisation, so I'll roll with the second for now. If this turns out to be only solution, though, it's a PITA hack to cover a shortfall of EE, given the core adds the nav_ prefix without documenting the behaviour, and then fails to handle it. – Alex Jun 11 '14 at 10:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.