ElkArte Community

Elk Development => Feature Discussion => Exterminated Features => Topic started by: IchBin on December 09, 2013, 12:58:05 pm

Title: elk_array_insert()
Post by: IchBin on December 09, 2013, 12:58:05 pm
So am I just not doing this right? I tried to add a menu item with the new function that Spudzor added, but can't seem to get it to work.

Code: [Select]
		$forum = array(
'forum' => array(
'title' => 'Forum',
'href' => $scripturl . '?action=forum',
'show' => true,
),
);
elk_array_insert($buttons, $buttons['admin'], $forum);
Title: Re: elk_array_insert()
Post by: emanuele on December 09, 2013, 01:56:37 pm
/me thinks:
Code: [Select]
		$forum = array(
'forum' => array(
'title' => 'Forum',
'href' => $scripturl . '?action=forum',
'show' => true,
),
);
elk_array_insert($buttons, 'admin', $forum);
Title: Re: elk_array_insert()
Post by: IchBin on December 10, 2013, 10:10:41 am
Yeah I tried that, it didn't work either...  >:(
Title: Re: elk_array_insert()
Post by: emanuele on December 10, 2013, 10:26:46 am
We didn't grab the return... :P

Code: [Select]
$buttons = elk_array_insert($buttons, 'admin', $forum);
Title: Re: elk_array_insert()
Post by: IchBin on December 10, 2013, 11:45:30 am
duh.... lol. Thanks ema!

Does this function deal with putting something in with a sub menu item? If I wanted to put the forum button in the community button? I don't see it handling this from what I understand.
Title: Re: elk_array_insert()
Post by: Spuds on December 10, 2013, 12:06:02 pm
Sorry about that, but yeah you have to use the return vs any pass by ref thing. 

For sub array things, it has to be passed the sub array, so something like (if I understand what you are asking)
Code: [Select]
function integrate_menu_buttons_sauce(&$buttons, &$menu_count)
{
$insert_after = 'calendar';

// Define the new menu item(s)
$new_menu = array(
'sauce' => array(
'title' => $txt['tasty'],
'href' => 'go here',
'show' => true
)
);

$buttons['home']['sub_buttons'] = elk_array_insert($buttons['home']['sub_buttons'], $insert_after, $new_menu, 'after');
}
Title: Re: elk_array_insert()
Post by: IchBin on December 10, 2013, 04:54:26 pm
Ahhh specifics... funny how you can look at something one way. Thanks for that Spuds!