Skip to main content
Topic: elk_array_insert() (Read 6405 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

elk_array_insert()

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);
Success is not the result of spontaneous combustion, you must set yourself on fire!

Re: elk_array_insert()

Reply #1

 emanuele thinks:
Code: [Select]
		$forum = array(
'forum' => array(
'title' => 'Forum',
'href' => $scripturl . '?action=forum',
'show' => true,
),
);
elk_array_insert($buttons, 'admin', $forum);
Bugs creator.
Features destroyer.
Template killer.

Re: elk_array_insert()

Reply #2

Yeah I tried that, it didn't work either...  >:(
Success is not the result of spontaneous combustion, you must set yourself on fire!

Re: elk_array_insert()

Reply #3

We didn't grab the return... :P

Code: [Select]
$buttons = elk_array_insert($buttons, 'admin', $forum);
Bugs creator.
Features destroyer.
Template killer.

Re: elk_array_insert()

Reply #4

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.
Last Edit: December 10, 2013, 11:56:29 am by IchBin
Success is not the result of spontaneous combustion, you must set yourself on fire!

Re: elk_array_insert()

Reply #5

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');
}

Re: elk_array_insert()

Reply #6

Ahhh specifics... funny how you can look at something one way. Thanks for that Spuds!
Success is not the result of spontaneous combustion, you must set yourself on fire!