Advertisement:

Author Topic: Menu without limit level  (Read 35127 times)

Offline davidhs

  • Sr. Member
  • ****
  • Posts: 936
  • Gender: Male
Menu without limit level
« on: March 08, 2010, 03:47:03 PM »
Link to Mod

Menu without limit level

ABOUT...

Menu without limit level, 1.0.11
© 2010-2015 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.


EXAMPLE

To create this menu, similar to the image,

Quote
Menu 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

can modify the file Sources/Subs.php

Quote
In function setupMenuContext() add code
Code: [Select]
'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,
),
'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,
),
),
),
),
),

or use integration hooks

Quote
1. Create the file Sources/Subs-MenuMultiLevel.php with content
Code: [Select]
<?php

if (!defined('SMF'))
die('Hacking attempt...');

function 
menu_multi_level(&$buttons)
{
$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,
),
'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,
),
),
),

),
);

}
}

}

?>

2. In file Sources/Load.php, find
Code: [Select]
// Integration is cool.
if (defined('SMF_INTEGRATION_SETTINGS'))
{
$integration_settings = unserialize(SMF_INTEGRATION_SETTINGS);
foreach ($integration_settings as $hook => $function)
add_integration_function($hook, $function, false);
}
and add after
Code: [Select]
add_integration_function('integrate_menu_buttons', 'menu_multi_level', false);
add_integration_function('integrate_pre_include', '$boarddir/Sources/Subs-MenuMultiLevel.php', false);

SMF COMPATIBILITY

  • SMF 2.0 to 2.0.15.

DOWNLOAD

Link to MOD

MANUAL INSTALLATION

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

SUPPORT AND COMMENTS

In English: http://www.simplemachines.org/community/index.php?topic=369595.0
In Spanish: http://www.simplemachines.org/community/index.php?topic=367071.0

CHANGE LOG

Code: [Select]
Legend:   ! Fixed   + Added   - Removed   * Changed   @ Note

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 http://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.
« Last Edit: May 24, 2015, 06:59:03 AM by Illori »

Offline Sabre™

  • SMF Hero
  • ******
  • Posts: 2,527
  • Gender: Male
  • IF IT AINT BROKE, I CAN FIX IT TILL IT IS!!
Re: MenuWithoutLimitLevel
« Reply #1 on: March 08, 2010, 10:44:35 PM »
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 ;)


Offline davidhs

  • Sr. Member
  • ****
  • Posts: 936
  • Gender: Male
Re: MenuWithoutLimitLevel
« Reply #2 on: March 09, 2010, 06:21:50 AM »
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.

Offline Sabre™

  • SMF Hero
  • ******
  • Posts: 2,527
  • Gender: Male
  • IF IT AINT BROKE, I CAN FIX IT TILL IT IS!!
Re: MenuWithoutLimitLevel
« Reply #3 on: March 09, 2010, 10:43:59 AM »
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 ;)


Offline Kreator

  • Jr. Member
  • **
  • Posts: 225
  • Gender: Male
    • Anim8orWorld on Facebook
    • Anim8orWorld
Re: MenuWithoutLimitLevel
« Reply #4 on: March 10, 2010, 11:20:19 AM »
Hmm, can someone explain what this actually does? I dloaded it , installed ok but nothing happens.

Must I change css or something?

Offline davidhs

  • Sr. Member
  • ****
  • Posts: 936
  • Gender: Male
Re: MenuWithoutLimitLevel 1.0.1 (SMF 2.0 RC2, 2.0 RC3)
« Reply #5 on: March 10, 2010, 01:22:46 PM »
Only works with default theme.
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.

Offline KensonPlays

  • SMF Hero
  • ******
  • Posts: 4,297
Re: MenuWithoutLimitLevel 1.0.1 (SMF 2.0 RC2, 2.0 RC3)
« Reply #6 on: March 10, 2010, 02:05:02 PM »
I can't find admin menu area!

Offline davidhs

  • Sr. Member
  • ****
  • Posts: 936
  • Gender: Male
Re: MenuWithoutLimitLevel 1.0.1 (SMF 2.0 RC2, 2.0 RC3)
« Reply #7 on: March 11, 2010, 06:29:05 AM »
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.

Offline KensonPlays

  • SMF Hero
  • ******
  • Posts: 4,297
Re: MenuWithoutLimitLevel 1.0.1 (SMF 2.0 RC2, 2.0 RC3)
« Reply #8 on: March 11, 2010, 10:17:38 AM »
Yes, like Tyrssons' mod, but limit of five, and no sub-sub-drop downs and the like :(

Offline Kreator

  • Jr. Member
  • **
  • Posts: 225
  • Gender: Male
    • Anim8orWorld on Facebook
    • Anim8orWorld
Re: MenuWithoutLimitLevel 1.0.1 (SMF 2.0 RC2, 2.0 RC3)
« Reply #9 on: March 11, 2010, 10:19:13 AM »
I`m using default theme, perhaps some help on how to use this might not go amiss?

Offline KensonPlays

  • SMF Hero
  • ******
  • Posts: 4,297
Re: MenuWithoutLimitLevel 1.0.1 (SMF 2.0 RC2, 2.0 RC3)
« Reply #10 on: March 11, 2010, 10:23:46 AM »
So this won't work on ANY other theme? No way at all possible?

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 68,035
    • Arantor on GitHub
Re: MenuWithoutLimitLevel 1.0.1 (SMF 2.0 RC2, 2.0 RC3)
« Reply #11 on: March 11, 2010, 10:47:12 AM »
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.
To assume is to hope that those who came before had the presence of mind and capacity to implement the dreams of those who would come after.

You either die a hero or live long enough to see yourself become the villain. It seems you have chosen which, and now I must do the same.

Offline KensonPlays

  • SMF Hero
  • ******
  • Posts: 4,297
Re: MenuWithoutLimitLevel 1.0.1 (SMF 2.0 RC2, 2.0 RC3)
« Reply #12 on: March 11, 2010, 10:50:22 AM »
Yes, I have like 5-6 curve variations, they said they installed successfully. But for themes like raven and "blue theem V2" didn't

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 68,035
    • Arantor on GitHub
Re: MenuWithoutLimitLevel 1.0.1 (SMF 2.0 RC2, 2.0 RC3)
« Reply #13 on: March 11, 2010, 10:51:11 AM »
Yeah, that's because they're not using standard Curve code, which is directly related to what I said above.
To assume is to hope that those who came before had the presence of mind and capacity to implement the dreams of those who would come after.

You either die a hero or live long enough to see yourself become the villain. It seems you have chosen which, and now I must do the same.

Offline KensonPlays

  • SMF Hero
  • ******
  • Posts: 4,297
Re: MenuWithoutLimitLevel 1.0.1 (SMF 2.0 RC2, 2.0 RC3)
« Reply #14 on: March 11, 2010, 10:54:16 AM »
ah...

Offline davidhs

  • Sr. Member
  • ****
  • Posts: 936
  • Gender: Male
Re: MenuWithoutLimitLevel 1.0.1 (SMF 2.0 RC2, 2.0 RC3)
« Reply #15 on: March 12, 2010, 12:17:49 PM »
I put in the first post an example code to add a menu.

Offline KensonPlays

  • SMF Hero
  • ******
  • Posts: 4,297
Re: MenuWithoutLimitLevel 1.0.1 (SMF 2.0 RC2, 2.0 RC3)
« Reply #16 on: March 12, 2010, 02:15:13 PM »
thanks!

Offline Sakae

  • Full Member
  • ***
  • Posts: 498
  • Gender: Male
    • TigreLOG
Re: MenuWithoutLimitLevel 1.0.1 (SMF 2.0 RC2, 2.0 RC3)
« Reply #17 on: March 14, 2010, 08:22:32 PM »
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

Offline davidhs

  • Sr. Member
  • ****
  • Posts: 936
  • Gender: Male
Re: MenuWithoutLimitLevel 1.0.1 (SMF 2.0 RC2, 2.0 RC3)
« Reply #18 on: March 15, 2010, 08:38:50 AM »
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

Code: [Select]
// 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
Code: [Select]
// 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.

Offline Sakae

  • Full Member
  • ***
  • Posts: 498
  • Gender: Male
    • TigreLOG
Re: MenuWithoutLimitLevel 1.0.1 (SMF 2.0 RC2, 2.0 RC3)
« Reply #19 on: March 15, 2010, 06:21:59 PM »
Thanks David!

Working great in my SMF 2.0 RC2!
http://www.tigrelog.com.br
l: simple p: machines