News:

Wondering if this will always be free?  See why free is better.

Main Menu

Adding custom menu options in 2.1

Started by @rjen, January 04, 2016, 01:16:59 PM

Previous topic - Next topic

@rjen

I have been playing around with a 2.1 beta forum for the last few days. My intention is to find out what I will need to move from 2.0 to 2.1 version sometime in te future.
My most valuable MODs (Tinyportal and Download system) seem to work ok with 2.1 now. Other mods not so important: they may of may be updated by the mod authors once 2.1 is stable.

The thing that I am trying to figure out now is how to add a few menu options into the menu. I do not want to use a menu block in TP (rather cumbersome), so looking for an update to the standaard menu. In attached screenshots an example from my 2.0.11 forum..

In 2.0.11 I have added some options with sub-menu's by updating the subs.php. Not very 'clean'  from a coding perspective, but it worked fine.
Now in 2.1 I am not sure if this is still possible in a relatively easy manner?

The two MODs I mentioned are using hooks ta add the menu options. I have not quite figured out how these work and I am quite sure that creating hooks for my extra options will be quite complicated. Can anyone tell me: is there a relatively easy way to add some extra menu options?

Running SMF 2.1 with latest TinyPortal at www.fjr-club.nl

Kindred

The main menu is still controlled in the array in Subs.php. That has not changed at all.
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

@rjen

Allright. Then I will just transfer the changes I made in the previous version... thanks. That was easy...
Running SMF 2.1 with latest TinyPortal at www.fjr-club.nl

@rjen

Almost there, I transferred the code menu options are there, but I am missing the icons.
I put them into the default/images folder end updated index.css


.generic_icons.forum_oud {
background: url(./images/forum_oud.png);
}
.generic_icons.Over_de_FJR {
background: url(./images/Over_de_FJR.png);
}
.generic_icons.Evenementen {
background: url(./images/Evenementen.png);
}
.generic_icons.Shop {
background: url(./images/Shop.png);
}


It does change something, but the images are not showing...
Running SMF 2.1 with latest TinyPortal at www.fjr-club.nl

Kindred

are those the actual ACTIONS?   (I doubt it, since most actions don't use caps)
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Illori

i believe you need ../ not just 1 dot in the file paths.

Kindred

oh yeah.... that too...

../images/generic_icons.png
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

@rjen

Quote from: Illori on January 04, 2016, 02:30:45 PM
i believe you need ../ not just 1 dot in the file paths.

oy, how silly can I be... that was it.

And these are indeed my own defined 'actions' in that are in Subs.php.  Works like a charm now...
Running SMF 2.1 with latest TinyPortal at www.fjr-club.nl

@rjen

Not all fine yet.

The menu options are there and showing, but the ' highlight'  of the active page or category menu is not working anymore.
I was using a URL grab (http://www.simplemachines.org/community/index.php?topic=399157.msg2773542#msg2773542) to determine the active menu option. This was working OK in 2.0 and I transferred the URL grab code to the 2.1 suns.php as well, but is doe not seem to work now. Menu options are nog highlighted anymore as these were in 2.0.

Any ideas?

A part of the amende subs.php code...


// AW ingevoerd URL grab noodzakelijk om menu opties te highlighten
$curPageURL = 'http';
if ( isset( $_SERVER["HTTPS"] ) && strtolower( $_SERVER["HTTPS"] ) == "on" ) {$curPageURL .= "s";}
$curPageURL .= "://";
if ($_SERVER["SERVER_PORT"] != "80")
{
$curPageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
}
else
{
$curPageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
}
// AW einde invoer URL grab

// Figure out which action we are doing so we can set the active tab.
// Default to home.
$current_action = 'home';

if (isset($context['menu_buttons'][$context['current_action']]))
$current_action = $context['current_action'];
elseif ($context['current_action'] == 'search2')
$current_action = 'search';
elseif ($context['current_action'] == 'theme')
$current_action = isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'pick' ? 'profile' : 'admin';
elseif ($context['current_action'] == 'register2')
$current_action = 'register';
elseif ($context['current_action'] == 'login2' || ($user_info['is_guest'] && $context['current_action'] == 'reminder'))
$current_action = 'login';
elseif ($context['current_action'] == 'groups' && $context['allow_moderation_center'])
$current_action = 'moderate';
elseif ($context['current_action'] == 'tpmod' && (isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'searcharticle'))
$current_action =  'search';
elseif ($context['current_action'] == 'tpmod' && (isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'searcharticle2'))
$current_action =  'search';
elseif ($context['current_action'] == 'unread')
$current_action = 'forum';
// $current_action = 'ongelezen';
elseif ($context['current_action'] == 'unreadreplies')
$current_action = 'forum';
// $current_action = 'ongelezen';
elseif ($context['current_action'] == 'recenttopics')
$current_action = 'forum';
elseif ($context['current_action'] == 'who')
$current_action = 'forum';
elseif ($context['current_action'] == 'recent')
$current_action = 'forum';
elseif ($context['current_action'] == 'stats')
$current_action = 'forum';
elseif ($curPageURL == $scripturl . '?cat=6')
$current_action = 'Over_de_FJR';
elseif ($curPageURL == $scripturl . '?page=3')
$current_action = 'Over_de_FJR';
elseif ($curPageURL == $scripturl . '?page=4')
$current_action = 'Over_de_FJR';
elseif ($curPageURL == $scripturl . '?page=5')
$current_action = 'Over_de_FJR';
elseif ($curPageURL == $scripturl . '?page=6')
$current_action = 'Over_de_FJR';
elseif ($curPageURL == $scripturl . '?page=7')
$current_action = 'Over_de_FJR';
elseif ($curPageURL == $scripturl . '?page=8')
$current_action = 'Over_de_FJR';
Running SMF 2.1 with latest TinyPortal at www.fjr-club.nl

@rjen

Follow up question after I upgraded my test forum to Beta3: I like the new mobile menu, that was needed.  :)

Now I find that because I have added a few menu options the Mobile menu is not quite as usefull, specifically on the smaller mobile screen (using a samsung galaxy S4 for this, so not even the smallest there is).

The menu is showing as an 'overlay' on the forum, but does not allow me to scroll: when I swipe up, the forum underneath the menu scrolls, but not the menu itself.  As you can see in attachment 1, the last menu option (logout) is not on screen anymore, and because I cannot scroll I cannot get to it. Problem is even worse when I open one of the submenu's (attachment 2), now multiple options fall off the screen...

It would be better if the menu itself could also be moved up to prevent this problem.
Hope this can be fixed in the next version?

You can see the example here: http://test.fjr-club.nl/
Running SMF 2.1 with latest TinyPortal at www.fjr-club.nl

Illori

you would be better posting this in the bugs board or even on github so we are sure it is noted by the developers that can fix it.

Advertisement: