News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

Menu without limit level

Started by davidhs, March 08, 2010, 03:47:03 PM

Previous topic - Next topic

davidhs

Link to Mod

Menu without limit level

ABOUT...

Menu without limit level, 3.0
© 2010-2021 by davidhs


This work is licensed under a Creative Commons Attribution 3.0 Unported License.

DESCRIPTION

Adds the possibility that the top menu of the forum has any number of levels.

Modifies:

  • Code which defines the menu to allow any number of levels.
  • Default theme to show up to 10 levels (main menu and 9 levels of submenus) because of CSS.

Also allows changing the menu structure in the Administration panel, using PHP code.

EXAMPLE

To create this menu,
QuoteMenu multi-level

  • Submenu 1 - level 1

    • Submenu 1.1 - level 2

      • Submenu 1.1.1 - level 3
      • Submenu 1.1.2 - level 3
    • Submenu 1.2 - level 2

      • Submenu 1.2.1 - level 3
      • Submenu 1.2.2 - level 3
    • Submenu 1.3 - level 2
  • Submenu 2 - level 1

    • Submenu 2.1 - level 2
    • Submenu 2.1 - level 2

the PHP code is this:
$buttons2 = $buttons;
$buttons = array();
foreach ($buttons2 as $i => $b)
{
$buttons[$i] = $b;
if ('home' == $i)
{
$buttons['m0'] = array(
'title' => 'Menu multi-level',
'href' => '',
'show' => true,
'sub_buttons' => array(
'm1' => array(
'title' => 'Submenu 1 - level 1',
'href' => '',
'show' => true,
'sub_buttons' => array(
'm11' => array(
'title' => 'Submenu 1.1 - level 2',
'href' => '',
'show' => true,
'sub_buttons' => array(
'm111' => array(
'title' => 'Submenu 1.1.1 - level 3',
'href' => '',
'show' => true,
'sub_buttons' => array(
'm1111' => array(
'title' => 'Submenu 1.1.1.1 - level 4',
'href' => '',
'show' => true,
),
'm1112' => array(
'title' => 'Submenu 1.1.1.2 - level 4',
'href' => '',
'show' => true,
),
),
),
'm112' => array(
'title' => 'Submenu 1.1.2 - level 3',
'href' => '',
'show' => true,
),
),
),

'm12' => array(
'title' => 'Submenu 1.2 - level 2',
'href' => '',
'show' => true,
'sub_buttons' => array(
'm121' => array(
'title' => 'Submenu 1.2.1 - level 3',
'href' => '',
'show' => true,
),
'm122' => array(
'title' => 'Submenu 1.2.2 - level 3',
'href' => '',
'show' => true,
),
),
),

'm13' => array(
'title' => 'Submenu 1.3 - level 2',
'href' => '',
'show' => true,
),
),
),

'm2' => array(
'title' => 'Submenu 2 - level 1',
'href' => '',
'show' => true,
'sub_buttons' => array(
'm21' => array(
'title' => 'Submenu 2.1 - level 2',
'href' => '',
'show' => true,
),
'm22' => array(
'title' => 'Submenu 2.2 - level 2',
'href' => '',
'show' => true,
),
),
),

),
);

}
}


SMF COMPATIBILITY


  • SMF 2.0 to 2.0.18.
  • SMF 2.1 Beta 3 and RC1 to RC3.

LANGUAGES


  • english, english_british.
  • spanish_es, spanish_latin.

DOWNLOAD

Link to MOD

MANUAL INSTALLATION

See https://wiki.simplemachines.org/smf/Manual_installation_of_mods

COLLABORATE WITH THIS MOD

This work is licensed under a Creative Commons Attribution 3.0 Unported License.

You are free to share and adapt this MOD. Also you can collaborate in different ways:

  • Write comments, detect errors or suggest improvements in support topics in English and in Spanish.
  • Translate the mod into other languages, adding the translation in support topics.
  • Help to expand my collection of coins, banknotes and stamps, sending me something from your country via postal mail (ask me for address by personal message).
  • Make a donation via PayPal.

CHANGE LOG

Legend:   ! Fixed   + Added   - Removed   * Changed   @ Note

3.0     2021-02-17
------------------
@ In previous versions the menu was modified in a file (named Subs-MenuWithoutLimitLevel-Menu.php from version 2.0, and with any name in previous versions). Now the menu is modified from the Administration panel. You must copy the content of the file in the field of panel, and delete the file.
+ Administration panel.
+ Allows changing the menu structure in the Administration panel, using PHP code.
+ The Quick Search of the Administration Center look for in settings variables of MOD.
+ SMF compatibility: 2.0.16-2.0.18 and 2.1 RC3.
+ Languages: english, english-utf8, english_british, english_british-utf8, spanish_es, spanish_es-utf8, spanish_latin, spanish_latin-utf8.

2.0.1   2019-04-09
------------------
+ SMF compatibility: 2.1 RC1 to RC2.

2.0     2017-12-20
------------------
@ In previous versions manual changes were necessary in the Sources/Load.php file. They are no longer necessary and must be undone.
@ In previous versions the PHP file where the menu is modified could have any name. Now it must be named Subs-MenuWithoutLimitLevel-Menu.php. If it exists with another name it must be renamed. And the function must be named mwllMenuButtons.
* Uses integration hooks.
+ SMF compatibility: 2.0.8-2.0.15 and 2.1 Beta 3.

1.0.11  2014-01-24
------------------
! Error in source code.
+ SMF compatibility: 2.0.7.

1.0.10  2013-10-24
------------------
+ SMF compatibility: 2.0.6.

1.0.9   2013-08-18
------------------
@ This work is licensed under a Creative Commons Attribution 3.0 Unported License https://creativecommons.org/licenses/by/3.0/
+ SMF compatibility: 2.0.5.

1.0.8   2013-04-09
------------------
+ SMF compatibility: 2.0.4.
- SMF compatibility: Support to RC versions.

1.0.7   2012-12-22
------------------
+ SMF compatibility: 2.0.3.

1.0.6   2011-12-24
------------------
! Some modifications of index.css of theme are not neccesary.
+ SMF compatibility: 2.0.2.

1.0.5   2011-09-20
------------------
+ SMF compatibility: 2.0.1.

1.0.4   2011-06-18
------------------
+ SMF compatibility: 2.0.

1.0.3   2011-02-13
------------------
+ SMF compatibility: 2.0 RC5.

1.0.2   2010-11-04
------------------
+ SMF compatibility: 2.0 RC4.

1.0.1   2010-03-10
------------------
! In 2.0 RC2, levels 4 and more show and hide at a time.
+ SMF compatibility: 2.0 RC3.

1.0     2010-03-08
------------------
+ SMF compatibility: 2.0 RC2.
+ Themes: default.

Sabre™

Nice mod :)
Something's up on the mod page with the parse/download section.
I cannot choose to parse the mod.
Do NOT give admin and/or ftp details to just anybody, see if they are trust worthy first!!  Do your homework ;)


davidhs

As I feel the same, I do not know of that will. Last night I got an update and they may have to revise it.

Sabre™

Yes, it is a slight mishap that the team or whoever has contact with that side can fix.
Do NOT give admin and/or ftp details to just anybody, see if they are trust worthy first!!  Do your homework ;)


Kreator

Hmm, can someone explain what this actually does? I dloaded it , installed ok but nothing happens.

Must I change css or something?

davidhs

Only works with default theme.
Quote from: davidhs on March 08, 2010, 03:47:03 PM
Modifies:

  • Code which defines the menu to allow any number of levels.
  • Default theme to show up to 10 levels (main menu and 9 levels of submenus) because of CSS.

Add support for SMF 2.0 RC3.

KensonPlays


davidhs

This MOD does not create an admin menu area, only allow the menu to display more levels in the default theme. The menu is modify as usual in Sources/Subs.php, function setupMenuContext()

For what you say I think there are other MODs.

KensonPlays

Yes, like Tyrssons' mod, but limit of five, and no sub-sub-drop downs and the like :(

Kreator

I`m using default theme, perhaps some help on how to use this might not go amiss?

KensonPlays

So this won't work on ANY other theme? No way at all possible?

Arantor

It could be made to work on other themes without so much effort though.

Firstly, move the custom CSS into its own file, and get the installer to install that to $themes_dir/default/menu.css

Then add a line to the source (probably Load.php or index.php, I forget exactly where) to add an entry to $context['html_headers'] to call for that CSS file with a suitable <link> item.

The theme edits look like they'd apply to any of the Curve based themes without much effort through the package manager's own methods for installing on other themes.

KensonPlays

Yes, I have like 5-6 curve variations, they said they installed successfully. But for themes like raven and "blue theem V2" didn't

Arantor

Yeah, that's because they're not using standard Curve code, which is directly related to what I said above.


davidhs

I put in the first post an example code to add a menu.


Sakae

Very nice and useful in my forum (check it the info icon on the menu).

How do I hide the "..."?
http://www.tigrelog.com.br
l: simple p: machines

davidhs

Quote from: Sakae on March 14, 2010, 08:22:32 PM
How do I hide the "..."?

Two options:

1. Before install my MOD:
1.1. Unzip (un giz, un tar) the mod *.tar.gz.
1.2. Edit file theme-default.xml and replace this

// BEGIN MOD MenuWithoutLimitLevel
// Show menu sub levels
function template_menu_sub_buttons($button)
{
// any subbuttons then?
if(!empty($button['sub_buttons']))
{
echo '
<ul>';
foreach ($button['sub_buttons'] as $sbutton)
{
echo '
<li>
<a', ((empty($sbutton['active_button'])) ? '' : ' class="active"'), ' href="', $sbutton['href'], '"', ((isset($sbutton['target'])) ? (' target="' . $sbutton['target'] . '"') : ''), '>
<span', ((isset($sbutton['is_last'])) ? ' class="last"' : ''), '>', $sbutton['title'], ((empty($sbutton['sub_buttons'])) ? '' : '...'), '</span>
</a>';
template_menu_sub_buttons($sbutton);
echo '
</li>';
}
echo '
</ul>';
}
}
// END MOD MenuWithoutLimitLevel

with this
// BEGIN MOD MenuWithoutLimitLevel
// Show menu sub levels
function template_menu_sub_buttons($button)
{
// any subbuttons then?
if(!empty($button['sub_buttons']))
{
echo '
<ul>';
foreach ($button['sub_buttons'] as $sbutton)
{
echo '
<li>
<a', ((empty($sbutton['active_button'])) ? '' : ' class="active"'), ' href="', $sbutton['href'], '"', ((isset($sbutton['target'])) ? (' target="' . $sbutton['target'] . '"') : ''), '>
<span', ((isset($sbutton['is_last'])) ? ' class="last"' : ''), '>', $sbutton['title'], '</span>
</a>';
template_menu_sub_buttons($sbutton);
echo '
</li>';
}
echo '
</ul>';
}
}
// END MOD MenuWithoutLimitLevel


1.3. Save the file
1.4. Zip all (in tar.gz or zip, is the same)

2. After intall my MOD: Do the same of step 1.2, but in file /Themes/default/index.template.php of your forum.

Sakae

http://www.tigrelog.com.br
l: simple p: machines

Advertisement: