News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

Menu without limit level

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

Previous topic - Next topic

thellie

hi, i've got it working, and it's exactly what i need... with the exception of permissions.

can some one have a quick look and tell me where i'm going wrong with the following code... i want to permission off certain levels dependent on membergroups, but can't quite work it out... a magnum of gratitude to the first one to help (correctly) :)

// Ecotours Project external pages menu
'ea' => array(
'title' => 'EcoAdmin',
'href' => '',
'show' => true,
'sub_buttons' => array(
   if (in_array(array(1,21,22), $user_info['groups']))
   {
'ea1' => array(
'title' => 'Ecotours Staff',
'href' => '',
'show' => true,
'sub_buttons' => array(
'ea11' => array(
'title' => 'Volunteer Administration / การบริหาร',
'href' => '',
'show' => true,
'sub_buttons' => array(
'ea111' => array(
'title' => 'Next intake of volunteers / ถัดไป',
'href' => $scripturl . '/page,page3981.html',
'show' => true,
),
'ea112' => array(
'title' => 'Latest volunteers / ล่าสุด',
'href' => $scripturl . '/page=pageXXXX.html',
'show' => true,
),
'ea113' => array(
'title' => 'Present volunteers / ปัจจุบัน',
'href' => $scripturl . '/page=page3835.html',
'show' => true,
),
'ea114' => array(
'title' => 'Active volunteers / ปัจจุบันกับในวันหน้า',
'href' => $scripturl . '/page=page1469.html',
'show' => true,
),
'ea115' => array(
'title' => 'Future volunteers / ในวันหน้า',
'href' => $scripturl . '/page=page366.html',
'show' => true,
),
'ea116' => array(
'title' => 'Past volunteers / ก่อน',
'href' => $scripturl . '/page=pageXXX.html',
'show' => true,
),
'ea117' => array(
'title' => 'All volunteers / ทุกคน',
'href' => $scripturl . '/page=pageXXXX.html',
'show' => true,
),
),
),
'ea12' => array(
'title' => 'Other information / ข้อมูลข่าวสารอื่น',
'href' => '',
'show' => true,
'sub_buttons' => array(
'ea121' => array(
'title' => 'Visa information / ข้อมูลวีซ่า',
'href' => '',
'show' => true,
),
'ea122' => array(
'title' => 'Submenu 1.2.2 - level 3',
'href' => '',
'show' => true,
),
),
),
'ea13' => array(
'title' => 'Submenu 1.3 - level 2',
'href' => '',
'show' => true,
),
),
),
   }

'ea2' => array(
'title' => 'Submenu 2 - level 1',
'href' => '',
'show' => true,
'sub_buttons' => array(
'ea21' => array(
'title' => 'Submenu 2.1 - level 2',
'href' => '',
'show' => true,
),
'ea22' => array(
'title' => 'Submenu 2.2 - level 2',
'href' => '',
'show' => true,
),
),
),

If you have any support questions, feel free to ask - be safe in the knowledge that I won't help because... I know nothing!

thellie

ok, so you can't have if statements inside arrays...

i've added the following in the function setupMenuContext()
   // Set up the menu privileges

$context['show_present_volunteers'] = (in_array(1, $user_info['groups']) || in_array(22, $user_info['groups']) || in_array(24, $user_info['groups']));
$context['show_past_volunteers'] = in_array(array(1,22,20), $user_info['groups']);


the first line works fine, but i'd like to tidy it up by having an array, ie second line... but can't get the syntax correct... can anyone help please?
If you have any support questions, feel free to ask - be safe in the knowledge that I won't help because... I know nothing!

excaliburj

Try:
$context['show_past_volunteers'] = (count(array_intersect(array(1,22,20), $user_info['groups'])) == 0 ? false : true);
Random Sig Line

thellie

excellent, works a treat :)

never would have got that on my own...

thanks very much!
If you have any support questions, feel free to ask - be safe in the knowledge that I won't help because... I know nothing!

thellie

just thinking... and i'll try it when i have the stuff i need to do first, done... this should be able to work on other existing menus shouldn't it?

for instance, i'd be interested in having external pages of articles written by volunteers.

so i could extend the articles menu button (came with smf articles), in exactly the same way, and have the href point to my pages...?

------------------------------------
oh, and i never said, but i'm running my forum on 2.0 rc3, and this mod works great :)
If you have any support questions, feel free to ask - be safe in the knowledge that I won't help because... I know nothing!

thellie

it's working really well on my testing server. i have one issue which is a requested addition to the mod.

can the delay be incorporated into the code somehow (i'd do it myself, but i don't know any javascript, and the stuff i looked at just confused the hell out of me) - i am going to get lots of comments about the menu disappearing as soon as the cursor wanders off the menu, so would love to pre-empt them if possible.
If you have any support questions, feel free to ask - be safe in the knowledge that I won't help because... I know nothing!

davidhs

Quote from: thellie on August 26, 2010, 11:38:48 PM
just thinking... and i'll try it when i have the stuff i need to do first, done... this should be able to work on other existing menus shouldn't it?

for instance, i'd be interested in having external pages of articles written by volunteers.

so i could extend the articles menu button (came with smf articles), in exactly the same way, and have the href point to my pages...?
I think it is possible, but depends on the code. I do not know.

Quote from: thellie on September 01, 2010, 01:18:33 AM
it's working really well on my testing server. i have one issue which is a requested addition to the mod.

can the delay be incorporated into the code somehow (i'd do it myself, but i don't know any javascript, and the stuff i looked at just confused the hell out of me) - i am going to get lots of comments about the menu disappearing as soon as the cursor wanders off the menu, so would love to pre-empt them if possible.
That would be very useful. But now I have not time. Maybe in a few months...

davidhs

New version:

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

davidhs

#28
New version:

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

davidhs

New version:

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

Zirc

#30
Okay so I have some errors showing up on my forums and I think they are related to this mod but can't figure out what the problem is so I'm hoping that somebody can help me out.

SMF 2.0

this is the error I'm getting -  8: Undefined index: href

And these are the two lines of my index.template.php of my custom theme that it is saying the error is coming on

This one I don't think is from the mod but it looks like it could be a related issue

<h4><a class="', $button['active_button'] ? 'active ' : '', 'firstlevel" href="', $button['href'], '"', isset($button['target']) ? ' target="' . $button['target'] . '"' : '', '>




This one is from the mod code

<a href="', $sbutton['href'], '"', isset($sbutton['target']) ? ' target="' . $sbutton['target'] . '"' : '', '>



I don't remember getting these errors on every page load before the 2.0 upgrade but I could be mistaken.  Any help with this issue would be great, thanks.

davidhs

I have not this error in SMF 2.0 forum for test

If you use my MOD, I suppose you have menu multi level. Perhaps problem are in your code when add your new menu items. In SMF 2.0 final you can use integration hooks instead of modify source code of YOUR_FORUM/Sources/Subs.php. You could apply these:

Step 1.- I suppose you have my MOD installed.

Step 2.- You create a new PHP file in YOUR_FORUM/Sources directory. In this file create a function for add your new menu. For example:
<?php

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

function 
menu_multi_level($buttons)
{
  global 
$txt// This line is necesary only if you write text of new menus in $txt vars 

  // In this function you can add, modify or remove items in $buttons array
  //
  // $buttons[] = ... // add new menu
}

?>

In my example I create a file with name Subs-MenuMultiLevel.php and source code:
<?php

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

// Adds my menu multi level between Home and Help
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,
),
),
),

),
);


}
}

}

?>


Step 3.- Add two lines in YOUR_FORUM/Sources/Load.php file, in line 282:
<?php

// Integration is cool.
if (defined('SMF_INTEGRATION_SETTINGS'))
{
$integration_settings unserialize(SMF_INTEGRATION_SETTINGS);
foreach ($integration_settings as $hook => $function)
add_integration_function($hook$functionfalse);
}

// NEW LINES
// Add access to new function
add_integration_function('integrate_menu_buttons''menu_multi_level'false);
// Include new file
add_integration_function('integrate_pre_include''$boarddir/Sources/Subs-MenuMultiLevel.php'false);
// END NEW LINES

// Any files to pre include?
if (!empty($modSettings['integrate_pre_include']))

?>


If do not work you can write in other post the source code of your menu items, and I could see if you have mistakes.

Jessica.

Testing Zone - SMF 2.0.7, default Curve
School & Chat - phpBB3, over 170 mods installed, official live forum

I use the latest version of Chrome

phpBB: Forum = a section; Board = whole site
SMF: Forum = whole site; Board = a section

Zirc

Quote from: Zirc on June 25, 2011, 08:24:02 PM
Okay so I have some errors showing up on my forums and I think they are related to this mod but can't figure out what the problem is so I'm hoping that somebody can help me out.

SMF 2.0

this is the error I'm getting -  8: Undefined index: href

And these are the two lines of my index.template.php of my custom theme that it is saying the error is coming on

This one I don't think is from the mod but it looks like it could be a related issue

<h4><a class="', $button['active_button'] ? 'active ' : '', 'firstlevel" href="', $button['href'], '"', isset($button['target']) ? ' target="' . $button['target'] . '"' : '', '>




This one is from the mod code

<a href="', $sbutton['href'], '"', isset($sbutton['target']) ? ' target="' . $sbutton['target'] . '"' : '', '>



I don't remember getting these errors on every page load before the 2.0 upgrade but I could be mistaken.  Any help with this issue would be great, thanks.

Okay so I found the problem after doing a Google search.  My issue was that I had some buttons that I didn't put a 'href' in there because I didn't want it to be clickable.  The solution was to just do 'href' => '#', for each of those buttons.  Thought this might help for anybody that gets the same issue.

MiY4Gi

Great mod. Just what I needed. Now I got a fully equipped, drop down forum menu.
Check out my new website, MyAnimeClub.net. I plan to create the largest anime community, and most fun and user-friendly anime forum in the world. It's still in the development stage though.

Zirc

I was wondering if somebody could help me out with this, should be an easy fix but I don't know how to do it.  When I am in the Admin section of the forums and I hover over a button that has a drop down the menu goes behind the admin buttons (see attached image) How can I fix this so the menu goes above the Admin buttons?

Thanks

SMF 2.0

davidhs

Now I can not see source code of SMF for test but... perhaps if you modify css file of your theme or default theme

DIR_FORUM/Themes/YOUR_THEME_OR_DEFAULT/css/index.css
line 1107 (in 2.0 RC5) /* Styles for the standard dropdown menus.
and next

davidhs

New version:

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

Zirc

Quote from: Zirc on August 21, 2011, 01:55:21 PM
I was wondering if somebody could help me out with this, should be an easy fix but I don't know how to do it.  When I am in the Admin section of the forums and I hover over a button that has a drop down the menu goes behind the admin buttons (see attached image) How can I fix this so the menu goes above the Admin buttons?

Thanks

SMF 2.0

I'm still having this problem and it's annoying so I'm attaching my index.css for the theme on the site in hopes that somebody can help.  Lines 4025 thru 4207 are the styles for the main navigation bar (the one whose dropdowns are going behind the adm_container).  I've tried adjusting the z-index of many different things and nothing seems to work so I'm back here looking for pointers.

Thanks

davidhs

Quote from: Zirc on November 04, 2011, 11:59:22 PM
Quote from: Zirc on August 21, 2011, 01:55:21 PM
I was wondering if somebody could help me out with this, should be an easy fix but I don't know how to do it.  When I am in the Admin section of the forums and I hover over a button that has a drop down the menu goes behind the admin buttons (see attached image) How can I fix this so the menu goes above the Admin buttons?

Thanks

SMF 2.0

I'm still having this problem and it's annoying so I'm attaching my index.css for the theme on the site in hopes that somebody can help.  Lines 4025 thru 4207 are the styles for the main navigation bar (the one whose dropdowns are going behind the adm_container).  I've tried adjusting the z-index of many different things and nothing seems to work so I'm back here looking for pointers.

Thanks
I think I solve your problem :). I copy your index.css in default theme of 2.0 forum and I have corrected it.

The problem is your theme (my MOD does not change anything important).

You must make changes to the file index.css. Line 3923
.dropmenu li ul
{
z-index: 200; // line 3923

replace by
.dropmenu li ul
{
z-index: 90; // line 3923


I suppouse this is all, but perhaps you need delete lines 3906 and 3918
z-index: 200;

Advertisement: