Correct way to add custom top menu items in 2.1.3?

Started by user58389239, May 17, 2023, 05:07:39 PM

Previous topic - Next topic

user58389239

Hi,
I tried copying our custom menu items from 2.0.19 in Subs.php to 2.1.3. Although the menu works, there are a lot of errors in the error log. I was following this old post which hasn't been updated since 2016.

Is the right way to create custom top menu items still editing Subs.php? Is there more detailed guidance anywhere on the best way to do it? Feeling a bit lost with all the arrays (I'm not a developer).


Illori

which top menu are you talking about? the one with home search etc in it? if so yes Subs.php is the way to edit it.


user58389239

Quote from: Illori on May 17, 2023, 05:10:49 PMwhich top menu are you talking about? the one with home search etc in it? if so yes Subs.php is the way to edit it.

Yes that's the one, are there any instructions anywhere for this and how to navigate Subs.php for it?

Thanks for the note about that mod, I'm glad to see it's compatible with 2.1.X! Maybe I'll give that a shot.


user58389239

Can anyone verify these instructions work for 2.1? The docs only reference 2.0.

Diego Andrés

It should be almost identical, it didn't change much at all.

SMF Tricks - Free & Premium Responsive Themes for SMF.


mickjav

Quote from: KTN on August 18, 2023, 10:25:37 AM
Quote from: mickjav on May 17, 2023, 05:31:59 PMYou could always try this mod

https://custom.simplemachines.org/index.php?mod=3674

After using that mod how to change the icon instead of ?

It's does't include a feature for adding A Icon

You could use a Hook but don't know what you're doing, so you'll have to decide if you can use it

add_integration_function('integrate_menu_buttons', __CLASS__ . '::menu_buttons#', false);
And a function to add the menu items, Note I use this in a mod I'm working on I've comments out some items you won't need it's just to give you an idea on what you'll need to do it you use a hook.

    public static function menu_buttons(&$buttons)
    {
        global $scripturl, $txt, $modSettings, $sourcedir;

        // Language
        //loadLanguage('Pledges/Pledges');
       

        //$total_waiting = self::PledgesToBeConfirmed();
        //$total_waiting = ($total_waiting ? ' (' . $total_waiting . ')' : '');

        // Menu Button
        $buttons['pledges'] = [
            'title' => (!empty($modSettings['pledges_title']) ? $modSettings['pledges_title'] : $txt['pledges_button']),
            'href' => $scripturl . '?action=pledge;area=pledge;sa=index',
            'icon' => 'pledges',
            'show' => (allowedTo('pledges_can_view_Pledges') && $modSettings['pledges_use_menu']),
            'sub_buttons' => [
                'pledgesinxex' => [
                    'title' => $modSettings['pledges_title'] . $txt['pledges_index_button'],
                    'href' => $scripturl . '?action=pledge;area=pledge;sa=index',
                    'show' => allowedTo('pledges_can_view_Pledges'),
                    ],
                'pledgesexpenses' => [
                    'title' => $txt['pledges_button_expence'],
                    'href' => $scripturl . '?action=pledge;area=pledge;sa=index;ds=expenses',
                    'show' => allowedTo('pledges_can_view_Pledges'),
                    ],
                'pledgesgoals' => [
                    'title' => $txt['pledges_goals_title'],
                    'href' => $scripturl . '?action=pledge;area=pledge;sa=goals',
                    'show' => allowedTo('pledges_can_view_Pledges'),
                    ],
                'pledgesconfirm' => [
                    'title' => $txt['pledges_confirm_pledges']. ' '.$modSettings['pledges_title'].$total_waiting,
                    'href' => $scripturl . '?action=pledge;area=pledge;sa=confirm',
                    'show' => allowedTo('pledges_can_edit_admin'),
                    ],
                'pledgesspend' => [
                    'title' => $txt['pledges_expense_menu'],
                    'href' => $scripturl . '?action=pledge;area=pledge;sa=spend',
                    'show' => allowedTo('pledges_can_edit_admin'),
                    ],
                'pledgeslists' => [
                    'title' => $txt['pledges_lists_title'],
                    'href' => $scripturl . '?action=pledge;area=pledge;sa=lists',
                    'show' => allowedTo('pledges_can_edit_admin'),
                    ],
                'pledgesconfig' => [
                    'title' => $txt['pledges_button_config'],
                    'href' => $scripturl . '?action=pledge;area=config',
                    'show' => allowedTo('pledges_can_edit_admin'),
                    ],
                'pledgesperms' => [
                    'title' => $txt['pledges_button_permissions'],
                    'href' => $scripturl . '?action=pledge;area=permissions',
                    'show' => allowedTo('pledges_can_edit_admin'),
                    ],
                ],
        ];
    }

KTN

I just add a menu button for the external link. It is working with mod. I just need an icon in front of the Text menu button.

Thanks,

Kindred

Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."


Advertisement: