News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Menu Editor Lite

Started by Matthew K., March 06, 2012, 01:05:26 PM

Previous topic - Next topic

Mstcool

It removes the forum link
how can i prevent that from happening

Matthew K.


Mstcool


Matthew K.

Read the readme..........that helps

NanoSector

Quote from: Mstcool on April 28, 2012, 03:55:08 PM
It removes the forum link
how can i prevent that from happening
That's the whole point of this mod, allowing you to edit the menu buttons...
My Mods / Mod Builder - A tool to easily create mods / Blog
"I've heard from a reliable source that the Answer is 42. But, still no word on what the question is."

Greybrow

I just love this menu editor. It made my life a lot easier.
But I wanted to have pm count on menu, so I hacked a bit and found a solution.

in Sources\menu_source\resources\main.php (should be line 899) change:
$buttons[$value['id_button']] = array(
'title' => $value['name'],
'href' => $value['href'],
'show' => true,
'target' => $value['target'],
'sub_buttons' => array(
),
'is_last' => $value['id_button'] == $menu_editor['last_button'] ? !$context['right_to_left'] : '',
'level' => 0
);
// Do we have Children?
if (!empty($menu_editor['children']['actual'][$value['id_button']]))
{
$buttons[$value['id_button']]['sub_buttons'] = array();
foreach ($menu_editor['children']['actual'][$value['id_button']] as $act => $sub_value)
{
// Introduce the Grandchildren - If we have any.
if (!empty($menu_editor['grandchildren']['actual'][$sub_value['id_button']]))
$temp[$sub_value['id_button']]['sub_buttons'] = $menu_editor['grandchildren']['actual'][$sub_value['id_button']];
else
$temp[$sub_value['id_button']]['sub_buttons'] = array();

// Actually add the Children!
$buttons[$sub_value['id_parent']]['sub_buttons'][$sub_value['id_button']] = array(
'title' => $sub_value['title'],

to:
// lets check if there are some unread pm and add the count if any
$title = '';
if ($context['user']['unread_messages'] > 0 && $value['href'] == $scripturl . '?action=pm')
$title = $value['name'] .' [<strong>' . $context['user']['unread_messages'] . '</strong>]';
else
$title = $value['name'];
// there goes the menu item
$buttons[$value['id_button']] = array(
'title' => $title,
'href' => $value['href'],
'show' => true,
'target' => $value['target'],
'sub_buttons' => array(
),
'is_last' => $value['id_button'] == $menu_editor['last_button'] ? !$context['right_to_left'] : '',
'level' => 0
);
// Do we have Children?
if (!empty($menu_editor['children']['actual'][$value['id_button']]))
{
$buttons[$value['id_button']]['sub_buttons'] = array();
foreach ($menu_editor['children']['actual'][$value['id_button']] as $act => $sub_value)
{
// lets check again if there are some unread pm and add the count if any to children
$title = '';
if ($context['user']['unread_messages'] > 0 && $sub_value['href'] == $scripturl . '?action=pm')
$title = $sub_value['title'] .' [<strong>' . $context['user']['unread_messages'] . '</strong>]';
else
$title = $sub_value['title'];
// Introduce the Grandchildren - If we have any.
if (!empty($menu_editor['grandchildren']['actual'][$sub_value['id_button']]))
$temp[$sub_value['id_button']]['sub_buttons'] = $menu_editor['grandchildren']['actual'][$sub_value['id_button']];
else
$temp[$sub_value['id_button']]['sub_buttons'] = array();

// Actually add the Children!
$buttons[$sub_value['id_parent']]['sub_buttons'][$sub_value['id_button']] = array(
'title' => $title,


It adds unread pm counter to menu item if you set it as internal link to personal messages.
I claim no copyright (it all goes to Labradoodle-360) and give no warranty that it works or destroys your forum.
But it works for me so I hope it helps.

Matthew K.

Thank you very much for your contribution, I just didn't have time to write the edit up for people. You could make it more streamline, although your code will still work efficiently, and for any link with ?action=pm in it, so even an external link, theoretically.

Although I would appreciate if you removed the package with the change, the code edit is great though :)

Thanks,
Matthew "Labradoodle-360" K.

Greybrow

Done :)
It should work only for internal links as it is $scripturl + ?action=pm

Yngwiedis

Hello...

When i make the above edit i get this error:
Parse error: syntax error, unexpected T_DOUBLE_ARROW in /home/********/public_html/Sources/menu_source/resources/main.php on line 900

Can you please help ?

Thank you.
AmityHost.com - The Affordable Host

Greybrow

Check again if you replaced the code properly.
Have you clicked [Select] and then copy?

Yngwiedis

Yes. I already try over 5 times.

The error is related with that line:
$title = '';
AmityHost.com - The Affordable Host

Greybrow

And you have replaced the old code with new, not just added it?

Yngwiedis

Yes. I replace the old code with the new code.
I am not so noob :)
AmityHost.com - The Affordable Host

Greybrow

:)
I don't know what could go wrong. It works for me just fine :)
So maybe try replace whole subsFunc1() function?
/**
* subsFunc1()
*
* @return
*/
function subsFunc1()
{

// Globalize everything we'll need...
global $scripturl, $context, $txt, $menu_editor;

// Redefine the array
$buttons = array();

// Call our items.
MenuItems();

// Top Level
if (!empty($menu_editor['actual']))
{
$menu_editor['first_button'] = reset($menu_editor['actual']);;
$menu_editor['last_button'] = end($menu_editor['actual']);
foreach ($menu_editor['actual'] as $key => $value)
{
// lets check if there are some unread pm and add the count if any
$title = '';
if ($context['user']['unread_messages'] > 0 && $value['href'] == $scripturl . '?action=pm')
$title = $value['name'] .' [<strong>' . $context['user']['unread_messages'] . '</strong>]';
else
$title = $value['name'];
// there goes the menu item
$buttons[$value['id_button']] = array(
'title' => $title,
'href' => $value['href'],
'show' => true,
'target' => $value['target'],
'sub_buttons' => array(
),
'is_last' => $value['id_button'] == $menu_editor['last_button'] ? !$context['right_to_left'] : '',
'level' => 0
);
// Do we have Children?
if (!empty($menu_editor['children']['actual'][$value['id_button']]))
{
$buttons[$value['id_button']]['sub_buttons'] = array();
foreach ($menu_editor['children']['actual'][$value['id_button']] as $act => $sub_value)
{
// lets check again if there are some unread pm and add the count if any to children
$title = '';
if ($context['user']['unread_messages'] > 0 && $sub_value['href'] == $scripturl . '?action=pm')
$title = $sub_value['title'] .' [<strong>' . $context['user']['unread_messages'] . '</strong>]';
else
$title = $sub_value['title'];
// Introduce the Grandchildren - If we have any.
if (!empty($menu_editor['grandchildren']['actual'][$sub_value['id_button']]))
$temp[$sub_value['id_button']]['sub_buttons'] = $menu_editor['grandchildren']['actual'][$sub_value['id_button']];
else
$temp[$sub_value['id_button']]['sub_buttons'] = array();

// Actually add the Children!
$buttons[$sub_value['id_parent']]['sub_buttons'][$sub_value['id_button']] = array(
'title' => $title,
'href' => $sub_value['href'],
'show' => true,
'target' => $sub_value['target'],
'sub_buttons' => $temp[$sub_value['id_button']]['sub_buttons'],
'is_last' => '',
'level' => 1
);
}
}
}
}
// No menu items? And we can admin? Show two items so we're not stuck! # Saves support time ::angel_smiley::
elseif (empty($menu_editor['actual']) && $context['allow_admin'])
{
$buttons = array(
'home' => array(
'title' => $txt['home'],
'href' => $scripturl,
'show' => true,
'target' => '_self',
'sub_buttons' => array(
),
'is_last' => $context['right_to_left'],
'level' => 0
),
'admin' => array(
'title' => $txt['admin'],
'href' => $scripturl . '?action=admin',
'show' => $context['allow_admin'],
'target' => '_self',
'sub_buttons' => array(
),
'is_last' => !$context['right_to_left'],
'level' => 0
)
);
}

// Then return the array to Subs.php!
return $buttons;

}

Yngwiedis

Now is working fine :)

Thank you very very much ;)
AmityHost.com - The Affordable Host

Greybrow

I suppose you deleted accidentally '{' from before $title='';
Glad it works :)

Yngwiedis

As i said before i just copy and paste.
Is very difficult to "delete accidentally" something for 5 times. 
:)
AmityHost.com - The Affordable Host

Matthew K.

There's no way you did a complete copy and paste...because his code is fine syntax wise. You had to have accidentally messed up some of the syntax prior to the block, or in the block.

Yngwiedis

I can give you my file to check for yourself.
I did everything as should be and i get the error i said.

Maybe is something incompatible with PHP version on my server or something like it...
AmityHost.com - The Affordable Host

Matthew K.

Nothing changed between the code he says to use, and the function he gave you...

Advertisement: