ElkArte Community

Extending Elk => Addons => Topic started by: live627 on February 27, 2015, 06:12:09 am

Title: [ADDON] Ultimate Menu
Post by: live627 on February 27, 2015, 06:12:09 am
Ultimate Menu 1.0

(https://camo.githubusercontent.com/d7b0ca6383644d5ac81e234f8d2249b731a1407b/687474703a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d3030393939392e737667) (http://opensource.org/licenses/MIT) (https://camo.githubusercontent.com/450c513f495e197d9d731246035723ba31366258/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f6c6976653632372f656c6b2d756d2e737667) (https://github.com/live627/elk-um/issues) (https://camo.githubusercontent.com/5d538550f4f301760ae1d39d83c42a63f648fbee/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f6c6976653632372f656c6b2d756d2e737667) (https://github.com/live627/elk-um/releases) (https://camo.githubusercontent.com/7c949223c0df91a43097422e9c84bdc84221ac37/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f646f776e6c6f6164732f6c6976653632372f656c6b2d756d2f746f74616c2e737667) (https://github.com/live627/elk-um/releases) (https://camo.githubusercontent.com/42369538c2c9e329a15d33929bcc9a2172dee3c4/68747470733a2f2f737570706f727465722e3630646576732e636f6d2f6170692f622f61786c736a316f386f30616d65706672723565716c636a7a61) (https://supporter.60devs.com/give/axlsj1o8o0amepfrr5eqlcjza)

Add custom buttons to the main menu within ElkArte

Introduction:

This allows custom buttons to be added to the main menu within ElkArte at will, complete with children and grandchildren menus (so, a main menu item, a dropdown and a follow-on dropdown)

Known issues:


http://addons.ElkArte.net/enhancement/Ultimate-Menu.html
Title: Re: [ADDON] Ultimate Menu
Post by: nhwood on February 27, 2015, 10:09:34 am
I suck at PHP so this will come in handy, thanks :)
I was hoping this would allow us to edit the current menu also but it's good enough.
Title: Re: [ADDON] Ultimate Menu
Post by: nhwood on February 27, 2015, 10:18:06 am
Found a bug
Title: Re: [ADDON] Ultimate Menu
Post by: Ant59 on February 27, 2015, 10:43:24 am
Awesome addon! I'm sure this will be helpful to a lot of people wanting to just add a few links to their menus without diving into their theme code. Is it possible to also remove the built-in options with this addon?
Title: Re: [ADDON] Ultimate Menu
Post by: live627 on February 27, 2015, 05:02:00 pm
Quote
Is it possible to also remove the built-in options with this addon?
No.
Title: Re: [ADDON] Ultimate Menu
Post by: emanuele on February 27, 2015, 08:38:40 pm
Nice stuff here too! :D
Title: Re: [ADDON] Ultimate Menu
Post by: meetdilip on March 02, 2015, 03:43:48 pm
Excellent @live627 . Love it :)
Title: Re: [ADDON] Ultimate Menu
Post by: Jorin on March 06, 2015, 07:49:16 am
Great! This comes in handy atm!  :)
Title: Re: [ADDON] Ultimate Menu
Post by: Jorin on March 06, 2015, 12:00:04 pm
Tried to install it and get these error message:

Quote
Parse error: syntax error, unexpected '[' in /www/htdocs/w00f21f1/hp_elkarte/packages/temp/install.php on line 87

Line 87 is this:

Code: [Select]
foreach ($tables as $table)
$dbtbl->db_create_table('{db_prefix}' . $table['name'], $table['columns'], $table['indexes'], [], 'update');
Title: Re: [ADDON] Ultimate Menu
Post by: Spuds on March 06, 2015, 02:54:35 pm
Thats php 5.4 shorthand syntax, change the
Code: [Select]
 , [], 
to
Code: [Select]
 , array(),
Title: Re: [ADDON] Ultimate Menu
Post by: emanuele on March 06, 2015, 02:56:41 pm
Problem is that the same construct is used in the code as well, so it would not work unless all the instances are replaced or you @Jorin update to php 5.4.
Title: Re: [ADDON] Ultimate Menu
Post by: Spuds on March 06, 2015, 02:58:59 pm
Ah good to know, had not looked at the code ... if thats the only 5.4 stuff easy to change though.
Title: Re: [ADDON] Ultimate Menu
Post by: Jorin on March 06, 2015, 04:03:37 pm
...or you @Jorin update to php 5.4.

Hm, server is running PHP 5.3. It seems I can "update" via PHP-CGI but I think I remember from my SMF support board that PHI-CGI should only be used with caution. Maybe @live627 can modify the addon?
Title: Re: [ADDON] Ultimate Menu
Post by: ahrasis on March 08, 2015, 01:36:26 am
Nice addon @live627
Title: Re: [ADDON] Ultimate Menu
Post by: live627 on March 08, 2015, 02:26:43 am
if thats the only 5.4 stuff easy to change though.
Yep.
Title: Re: [ADDON] Ultimate Menu
Post by: Jorin on March 13, 2015, 12:17:25 pm
Found a bug

Have this too.  :(
Title: Re: [ADDON] Ultimate Menu
Post by: Jorin on March 13, 2015, 12:55:33 pm
Another Bug. I created a child entry. It looks like this.
Title: Re: [ADDON] Ultimate Menu
Post by: Jorin on March 13, 2015, 01:18:20 pm
Urgs! An internal link leads to this:

Code: [Select]
http://forum-alternative-antriebe.de/index.php?/topic,467.0.html

when entering only:

Code: [Select]
/topic,467.0.html

I need it without the ?

 :o
Title: Re: [ADDON] Ultimate Menu
Post by: Jorin on March 13, 2015, 01:27:38 pm
And a third: I made more then one child entries. But they are not shown. It seems only one child entry is shown.

Edit: Now I know why! I cannot choose "before" or "after" for the location of a child entry (then it's not shown). I can only choose "child of" and choose the parent entry. So there's no chance to sort child entries atm.
Title: Re: [ADDON] Ultimate Menu
Post by: Jorin on March 13, 2015, 02:35:27 pm
Sorry, but it's not working without errors anyhow. After re-organization of the child entries all of them disappeared. After that I can't make new entries now. At the moment the first entry, the main one, will not collapse (they are child entries in it). I have to deactivate the addon, it doesn't work in my board.  :(
Title: Re: [ADDON] Ultimate Menu
Post by: ahrasis on March 14, 2015, 04:30:13 am
I need it without the ?

I don't think without ? is possible or is it possible @emanuele / @Spuds ?
Title: Re: [ADDON] Ultimate Menu
Post by: Jorin on March 14, 2015, 07:00:41 am
Oh, you're right. Why are my topic links look like that:

Quote
http://forum-alternative-antriebe.de/index.php/topic,4396.0.html

And yours look like that:

Quote
http://www.elkarte.net/community/index.php?topic=2310.0

:o
Title: Re: [ADDON] Ultimate Menu
Post by: emanuele on March 14, 2015, 10:16:14 pm
Honestly I never used that version of the links, so I have no idea at the moment.
Title: Re: [ADDON] Ultimate Menu
Post by: Spuds on March 14, 2015, 10:42:49 pm
Those are what you get if you enable "Search engine friendly URLs" in the ACP ... (configuration->general)
Title: Re: [ADDON] Ultimate Menu
Post by: Spuds on March 16, 2015, 04:13:16 pm
Was messing around a bit, not sure I really did anything :P  but did change a couple minor porting items and a couple of minor things.
Title: Re: [ADDON] Ultimate Menu
Post by: live627 on March 19, 2015, 09:16:03 am
Urgs! An internal link leads to this:

Code: [Select]
http://forum-alternative-antriebe.de/index.php?/topic,467.0.html

when entering only:

Code: [Select]
/topic,467.0.html

I need it without the ?

 :o
I guess you can try topic=467 (assuming the buffer fixes it, I haven't checked) or try the full external link option.

Honestly I never used that version of the links, so I have no idea at the moment.
me neither

Was messing around a bit, not sure I really did anything :P  but did change a couple minor porting items and a couple of minor things.
Thanks! Added to the repo.
Title: Re: [ADDON] Ultimate Menu
Post by: Jorin on March 19, 2015, 09:47:17 am
Those are what you get if you enable "Search engine friendly URLs" in the ACP ... (configuration->general)

So the experts don't use search enginge friendly URLs? Why not?  :o
Title: Re: [ADDON] Ultimate Menu
Post by: radu81 on March 19, 2015, 09:55:18 am
I'm not an expert, but I see non advantage in using this kind of links. Even a site like Youtube is not using friendly urls.

In the past I used on smf the Pretty URLS mod which I don't recommend, the site was getting slower and slower and the database bigger and bigger.
Title: Re: [ADDON] Ultimate Menu
Post by: live627 on March 19, 2015, 10:00:26 am
Found a bug
Elk bug. Problem areas highlighted.

input, .input_text, button, select {
    height: 2em;
    max-height: 2em;
    min-height: 2em;

    padding: 0 6px;
    vertical-align: middle;
}
Title: Re: [ADDON] Ultimate Menu
Post by: live627 on March 19, 2015, 10:03:33 am
Those are what you get if you enable "Search engine friendly URLs" in the ACP ... (configuration->general)
So the experts don't use search enginge friendly URLs? Why not?  :o
The only advantage is human readability. Spiders are not affected at all.
Title: Re: [ADDON] Ultimate Menu
Post by: live627 on March 19, 2015, 10:10:21 am
I cannot uninstall this despite

Code: [Select]
<uninstall for="1.0 - 1.0.99">
Title: Re: [ADDON] Ultimate Menu
Post by: Spuds on March 19, 2015, 02:38:56 pm
Those are what you get if you enable "Search engine friendly URLs" in the ACP ... (configuration->general)
So the experts don't use search enginge friendly URLs? Why not?  :o
The only advantage is human readability. Spiders are not affected at all.
It also only works "out of the box" on Apache/Lighttpd, and I use Nginx for almost everything these days.


Found a bug
Elk bug. Problem areas highlighted.
Yeah I've know about that one since RC days, there are a couple of override classes to "fix" that behavior where needed, but a generic class should be added as well, I'll toss something in for 1.04.  
Don't know what to say other than any form elements need to be beaten to death to get them to display properly across OS (and revisions), font stacks and browsers.  Probably worth a revisit in 1.1 but chasing down how those areas render across win/mac/*nix/ saf/ie/chrome/ff/etc 7/8/ml/mav/yos/unbu/cent/etc/blabla is not a whole lot of fun.  At one point I had a test setup with a combo matrix to see how those rendered (or did not) the differences were sometimes stunning.  At some point the same needs to be done or checked on, mobile devices as well bleh!

Title: Re: [ADDON] Ultimate Menu
Post by: Joshua Dickerson on March 19, 2015, 09:17:20 pm
Those are what you get if you enable "Search engine friendly URLs" in the ACP ... (configuration->general)

So the experts don't use search enginge friendly URLs? Why not?  :o
"Search engine friendly" is a misnomer. They are really just more friendly for humans but have no bearing for the major search engines.
Title: Re: [ADDON] Ultimate Menu
Post by: Jorin on March 20, 2015, 07:08:37 am
Do you prefer to change back to "normal" URLs? Is this possible for me?
Title: Re: [ADDON] Ultimate Menu
Post by: live627 on March 20, 2015, 07:29:16 am
Can someone split out the off-topic SEF URL posts?
Title: Re: [ADDON] Ultimate Menu
Post by: Obamatron on March 27, 2015, 02:38:08 pm
How about FontAwesone icons for mobile users?
Title: Re: [ADDON] Ultimate Menu
Post by: live627 on March 28, 2015, 01:59:17 am
Does Ellk's main menu support icons? I haven't checked...
Title: Re: [ADDON] Ultimate Menu
Post by: kode54 on January 20, 2016, 04:00:02 am
Issue/feature request: Allow defining a FontAwesome icon for the small screen view for top level menus.
Title: Re: [ADDON] Ultimate Menu
Post by: Jorin on January 20, 2016, 07:30:55 am
Huh? They do have an icon in mobile view which is a fontawesome icon and can be changed in the css files. What do you mean exactly?
Title: Re: [ADDON] Ultimate Menu
Post by: kode54 on January 20, 2016, 08:04:57 am
I am referring to this report (https://hydrogenaud.io/index.php/topic,110890.msg914717.html#msg914717).
Title: Re: [ADDON] Ultimate Menu
Post by: Jorin on January 20, 2016, 08:09:06 am
It seems the code must be copied to the section for mobile views. Should be in the css files too. But I don't know where.
Title: Re: [ADDON] Ultimate Menu
Post by: oblivion on February 25, 2016, 03:31:45 pm
I've installed this and configured a new menu item.  It doesn't show up for some custom member groups that inherit the regular member permissions.
Title: Re: [ADDON] Ultimate Menu
Post by: kode54 on April 02, 2016, 02:43:08 am
Icon picker. Add icon data attribute to links.

Or instead, I think I'll just eliminate the code that turns the top menu into incomprehensible icons on mobile devices. But that's ElkArte code or style, not this add-on.
Title: Re: [ADDON] Ultimate Menu
Post by: emanuele on April 02, 2016, 11:33:49 pm
Are you asking for an icon picker for the menu entries?
If so, I guess it would make sense, since icons are added in a nasty way in Elk.
Actually, you should still be able to add them via css alone (inside a media query), can't give you an example right now, sorry... :(
Title: Re: [ADDON] Ultimate Menu
Post by: live627 on July 18, 2016, 02:04:26 am
v1.0 is now officially released!

http://addons.elkarte.net/enhancement/Ultimate-Menu.html

Please do donate if you feel so inclined.  
Title: Re: [ADDON] Ultimate Menu
Post by: Jorin on July 18, 2016, 06:46:54 am
Great! I will give it another try!  :)
Title: Re: [ADDON] Ultimate Menu
Post by: Jorin on July 18, 2016, 08:05:17 am
I get three errors:

1. A long title for the button (or maybe the html code inside the title) makes it impossible to edit the title after saving the button. This happens if you edit a button with such a long title (attachment 1). Title I saved was:

Code: [Select]
<i class="fa fa-pencil" aria-hidden="true"></i> Entwürfe

2. It causes problems with my start page using bootstrap things (attachment 2). The button clicked is not shown active too. This is line 26 and following:

Code: [Select]
	// Make damn sure we ALWAYS load last. Priority: 100!
if (end(explode(',', $modSettings['integrate_menu_buttons'])) != 'um_load_menu')
{
remove_integration_function('integrate_menu_buttons', 'um_load_menu');
add_integration_function('integrate_menu_buttons', 'um_load_menu');
}

3. Icons made with addon are not shown in mobile view. There is only a white pixel shown.
Title: Re: [ADDON] Ultimate Menu
Post by: emanuele on July 18, 2016, 11:58:37 pm
The errors can be fixed by changing:
Code: [Select]
if (end(explode(',', $modSettings['integrate_menu_buttons'])) != 'um_load_menu')
to:
Code: [Select]
$hooks = explode(',', $modSettings['integrate_menu_buttons']);
if (end($hooks) != 'um_load_menu')
Title: Re: [ADDON] Ultimate Menu
Post by: Jorin on July 19, 2016, 07:11:09 am
The error is gone, thank you, but the three problems stay.
Title: Re: [ADDON] Ultimate Menu
Post by: Jorin on July 25, 2016, 09:17:47 am
Can the addon author please help me with the icons not shown in mobile view?  :-[

Edit: Would be nice if the user and group rights to see an menu icon or not were considered too.
Title: Re: [ADDON] Ultimate Menu
Post by: emanuele on July 25, 2016, 01:38:51 pm
1. A long title for the button (or maybe the html code inside the title) makes it impossible to edit the title after saving the button. This happens if you edit a button with such a long title (attachment 1). Title I saved was:

Code: [Select]
<i class="fa fa-pencil" aria-hidden="true"></i> Entwürfe
This is not a problem of long name, but of unsanitized data.
@live627 you should htmlspecialchars $context['button_data']['name'].
Jorin, for the time being you can fix it by changing:
Code: [Select]
<input type="text" name="name" id="bnbox" value="', $context['button_data']['name'], '" tabindex="1" class="input_text" style="width: 100%;" />
to:
Code: [Select]
<input type="text" name="name" id="bnbox" value="', Util::htmlspecialchars($context['button_data']['name']), '" tabindex="1" class="input_text" style="width: 100%;" />
in ManageUltimateMenu.template.php (default theme directory).
Title: Re: [ADDON] Ultimate Menu
Post by: emanuele on July 25, 2016, 01:55:17 pm
2. The button clicked is not shown active too.
Make it active is not really a trivial thing.
The status is defined by the "action", without a new action it's basically *very* difficult to make a button active.
The only way that comes to my mind, is to let specify an action and a subaction on which it will be selected as active, though, even that is an incomplete solution because there may be situations it won't work.
No good answer here, sorry.
And this is more a problem with the way Elk highlights the button than the menu editor.

3. Icons made with addon are not shown in mobile view. There is only a white pixel shown.
Something specific for that may be implemented in the menu editor, but at the moment, due to the way Elk handles icons in mobile view, you'd have to:
1) find the id of the button,
2) add a bit of css along the lines of:
Code: [Select]
#id_of_the_button .linklevel1:before {
font-family: 'FontAwesome';
    border: 3px solid #666;
    padding: 1px;
    margin: 2px;
    height: 1.15em;
    width: 1.15em;
    text-align: center;
    display: inline-block;
    border-radius: 4px;
    line-height: 1.2em;
    font-size: 2em;
    color: #666;
    content: 'the-code-of-the-fontawesome-icon-you-want';
}
For example, for your home page, it could be:
Code: [Select]
#button_f6f31cebde020d86add72bea0e662341-1468822676 .linklevel1:before {
font-family: 'FontAwesome';
    border: 3px solid #666;
    padding: 1px;
    margin: 2px;
    height: 1.15em;
    width: 1.15em;
    text-align: center;
    display: inline-block;
    border-radius: 4px;
    line-height: 1.2em;
    font-size: 2em;
    color: #666;
    content: '\f015';
}
while, for the Entwurfe button:
Code: [Select]
#button_6935862f74f620598b6b2549c202aafa-1468821375 .linklevel1:before {
font-family: 'FontAwesome';
    border: 3px solid #666;
    padding: 1px;
    margin: 2px;
    height: 1.15em;
    width: 1.15em;
    text-align: center;
    display: inline-block;
    border-radius: 4px;
    line-height: 1.2em;
    font-size: 2em;
    color: #666;
    content: '\f040';
}
Title: Re: [ADDON] Ultimate Menu
Post by: kode54 on July 25, 2016, 10:39:52 pm
Or suppose I wanted to use an .SVG as a button, I could reference it using some slightly different code for the CSS block. (For example, referring to the foobar2000 subforum with the foobar2000 icon.)
Title: Re: [ADDON] Ultimate Menu
Post by: kode54 on August 02, 2016, 01:54:49 am
I'm trying (unsuccessfully) to set a button with a .png or an .svg icon instead of a FontAwesome glyph. It's not even rendering the button if I set it as the background, and I can't seem to set content property to anything but raw text.
Title: Re: [ADDON] Ultimate Menu
Post by: live627 on August 02, 2016, 02:49:36 am
Can I see the code you added (I'm assuming CSS)?
Title: Re: [ADDON] Ultimate Menu
Post by: kode54 on August 02, 2016, 08:03:42 am
I attempted to add:
Code: [Select]
    #button_2cad931b9566e54811554d5f7fdc1e84-1451402398 .linklevel1:before {
        padding: 1px;
        margin: 2px;
        height: 1.15em;
        width: 1.15em;
        display: inline-block;
        background: url(//fb2k_icon.png) no-repeat;
        background-size: 100%;
    }

It doesn't render the button at all unless I add a content: ' ', and in that case, it lacks the background image.

Attempting to use content: url(//fb2k_icon.png) results in a lovely question mark image appearing in Safari.
Title: Re: [ADDON] Ultimate Menu
Post by: live627 on August 03, 2016, 12:58:19 am
try
Code: [Select]
content: url(../../fb2k_icon.png)
Title: Re: [ADDON] Ultimate Menu
Post by: kode54 on August 03, 2016, 06:47:24 am
I ended up settling on:

Code: [Select]
    #button_2cad931b9566e54811554d5f7fdc1e84-1451402398 .linklevel1:before {
        min-height: 40px;
        padding: 1px;
        padding-right: 41px;
        display: block;
        background-position: center;
        background-size: 40px 40px;
        background-repeat: no-repeat;
        background-image: url(../../fb2k_icon.png);
        content: "";
    }
Title: Re: [ADDON] Ultimate Menu
Post by: live627 on August 03, 2016, 06:54:28 am
rock on! ;D
Title: Re: [ADDON] Ultimate Menu
Post by: Jorin on August 03, 2016, 07:56:21 am
Make it active is not really a trivial thing.
The status is defined by the "action", without a new action it's basically *very* difficult to make a button active.
The only way that comes to my mind, is to let specify an action and a subaction on which it will be selected as active, though, even that is an incomplete solution because there may be situations it won't work.
No good answer here, sorry.
And this is more a problem with the way Elk highlights the button than the menu editor.

Okay, maybe with future versions of ElkArte there is a way?

As for the rest, thank you very much. I uninstalled the addon and made the menu in Subs.php on my own so it has icons in mobile view.  ;)
Title: Re: [ADDON] Ultimate Menu
Post by: live627 on August 08, 2016, 06:44:25 am
v1.1.1 has been released; changelog is at https://github.com/live627/elk-um/releases
Title: Re: [ADDON] Ultimate Menu
Post by: shaitan on February 06, 2017, 08:41:28 pm
Nice Addon, thank you.

French translation in attachment.
Title: Re: [ADDON] Ultimate Menu
Post by: live627 on February 10, 2017, 12:44:43 am
Thanks for the donation! Very much appreciated :)
Title: Re: [ADDON] Ultimate Menu
Post by: WittyUsernameSA on February 16, 2017, 10:54:11 pm
Got a question.

Using Ultimate Menu and Simple Portal pages,  I want to put some pages up in the menu. And that works great and all. But there's a visual issue that I have a problem with. Due to the way Simpleportal is set up, everything is driven by the homepage portal and every page acts like a child of the homepage. So, when I click the newly added simple portal page in the menu, it registers it as the homepage being active, which I find incredibly distracting:

(https://www.elkarte.net/community/imagecache.php?image=http%3A%2F%2Fdumpt.com%2Fimg%2Ffiles%2Fdt5xcocan584v1qmkb96.png&hash=43919223aeac09ad1046a42889c572a2" rel="cached" data-warn="External image, click here to view original" data-url="http://dumpt.com/img/files/dt5xcocan584v1qmkb96.png)

It's probably something that only bothers me, but I would like, when that particular link, is clicked, it'd show the test button as active. Otherwise, I really don't want to use Ultimate Menu.

I am using Mostly Blue:

http://www.elkarte.net/community/index.php?topic=3682.0

I'm wanting to ask for one of two possible solutions:

1. Editing a file in the theme to force in the menu rather than using ultimate menu (I don't think that's possible with UM, as it stands) so that when index.php?page=test (or whatever comes after =) appears, it shows that menu item as active.

2. If that's not doable due to the way Simpleportal handles items, I would like to remove the "active" graphic so that there's ONLY hover and inactive graphics. It'd suck to lose that, but it's merely a cosmetic and no one would miss it since they'd never know it existed.

If the author is still around, and knows of a way to fix this, I'd love to see it. Simpleportal is widely used, especially for its pages. This would be helpful for many.
Title: Re: [ADDON] Ultimate Menu
Post by: txcas on April 10, 2017, 03:02:56 pm
I would like to request mobile view support on this add-on.
Title: Re: [ADDON] Ultimate Menu
Post by: Frenzie on April 10, 2017, 03:12:05 pm
@txcas Could you clarify that a bit? What's the problem exactly? I use it and I don't see any trouble.
Title: Re: [ADDON] Ultimate Menu
Post by: live627 on April 11, 2017, 03:30:41 am
icons?
Title: Re: [ADDON] Ultimate Menu
Post by: txcas on April 12, 2017, 09:03:30 pm
@txcas Could you clarify that a bit? What's the problem exactly? I use it and I don't see any trouble.
I added a new menu for my site.  It shows on desktops, but no icon for the new menu on mobile devices.
Title: Re: [ADDON] Ultimate Menu
Post by: Frenzie on April 12, 2017, 09:16:30 pm
Ah, I've only worked with submenus. I'm not sure if the add-on should be expected to provide CSS styling, unless the problem is something more severe.
Title: Re: [ADDON] Ultimate Menu
Post by: russena on March 10, 2018, 03:35:21 pm
it's work with Elkarte 1.1.2?
Title: Re: [ADDON] Ultimate Menu
Post by: Mrs. Chaos on May 25, 2018, 06:21:01 pm
Hello!
Last night my hoster changed the php version of my account from PHP 5.5.38  to 7.2.1.
Now I found more than 90 pages with the same error in the error protocol. :o
Here' an example. The lines written in red are the same everywhere, the others are mostly different:

W4FfEyTf6lpT7fBqxHFmilZrES6gH10w
Type of error: General
Unknown Error: The each() function is deprecated. This message will be suppressed on further calls

https://forum.xxx.de/index.php?action=mentions;sa=fetch;api=json;lastsent=0

File: /www/htdocs/w00f7xxx/forum/sources/subs/UltimateMenu.subs.php
Line: 41


Line 41 in the UltimateMenu.subs.php is the 3rd here -> while (list(, $row) = each($db_buttons)) {

Code: [Select]
    // Insert the items in to the site menu as defined in the um ACP
    reset($db_buttons);
    while (list(, $row) = each($db_buttons)) {
        // UM menu button basics
        $temp_menu = array(
            'title' => $row['name'],
            'href' => ($row['type'] === 'forum' ? $scripturl . '?' : '') . $row['link'],
            'target' => $row['target'],
            'show' => (allowedTo('admin_forum') || count(array_intersect($user_info['groups'], explode(',', $row['permissions']))) >= 1) && $row['status'] === 'active',
        );

What's wrong there?
.
Title: Re: [ADDON] Ultimate Menu
Post by: tino on May 25, 2018, 07:24:15 pm
I think changing it from

Code: [Select]
 while (list(, $row) = each($db_buttons)) { 

to

Code: [Select]
 foreach ( $db_buttons as $id => $row) { 

should be the same...
Title: Re: [ADDON] Ultimate Menu
Post by: Mrs. Chaos on May 25, 2018, 08:26:31 pm
Yes, that helps.
The errors stay away now.
Thanks a lot!
Title: Re: [ADDON] Ultimate Menu
Post by: bea on May 25, 2018, 09:18:01 pm
I think changing it from

Code: [Select]
 while (list(, $row) = each($db_buttons)) { 

to

Code: [Select]
 foreach ( $db_buttons as $id => $row) { 

should be the same...

AFAIK, older versions of PHP were lacking the foreach construct, and the each() functions was a workaround to it. Now that there is a foreach loop, the workaround is not necessary anymore and becomes deprecated. Which might cause some trouble for users of older machines.
Title: Re: [ADDON] Ultimate Menu
Post by: Mrs. Chaos on May 25, 2018, 09:47:11 pm
Thanks for the explanation!
Title: Re: [ADDON] Ultimate Menu
Post by: Mrs. Chaos on June 26, 2018, 05:35:26 pm
After the update to ElkArte 1.1.4  I get this error message for three lines (167, 183 and 216), if I go to the Ultimate Menu in the ACP:

Unknown Error: Function create_function() is deprecated
https://forum.website.de/index.php?action=admin;area=umen;sa=manmenu;lC6YqBG=ug0ThYsUqmmXa9Afj6CjjDCu77ZB9HWn
-> ManageUltimateMenu.controller.php

Can someone help, please?
Title: Re: [ADDON] Ultimate Menu
Post by: tino on June 26, 2018, 08:18:29 pm
That’s due to your version of php you’re running, not the Elkarte update.

They need to be changed to anonymous functions. http://php.net/manual/en/functions.anonymous.php

I can’t look at it now but should be able to tomorrow if you can’t work out the changes.
Title: Re: [ADDON] Ultimate Menu
Post by: Mrs. Chaos on June 26, 2018, 09:12:15 pm
Aha, the PHP version is to blame . It's now PHP 7.2.1.

It would be nice if you did that for me. I've looked at it and understood only a little... O:-)
Title: Re: [ADDON] Ultimate Menu
Post by: ahrasis on June 27, 2018, 01:34:11 am
It simply means to convert all create_function to function. It shouldn't be that hard. Find and list them here if you are not sure.
Title: Re: [ADDON] Ultimate Menu
Post by: Mrs. Chaos on June 27, 2018, 04:55:52 pm
To do it by myself unfortunately exceeds my knowledge.
Here are the parts with create_function in it. It's always in the second line.
The complete page is attached below.

Code: [Select]
                    'data' => array(
                        'function' => create_function('$rowData', '
                            global $txt;

                            return $txt[$rowData[\'type\'] . \'_link\'];
                        '),
                    ),

Code: [Select]
                    'data' => array(
                        'function' => create_function('$rowData', '
                            global $txt;

                            // Don\'t show the stub name if we can find the parent name
                            $check = common_um_name($rowData[\'parent\']);
                            $name = !empty($check) ? $check : $rowData[\'parent\'];

                            return $txt[\'mboards_order_\' . $rowData[\'position\']] . \' \' . ucwords($name);
                        '),
                    ),

Code: [Select]
                    'data' => array(
                        'function' => create_function('$rowData', '
                            global $txt;

                            $isChecked = $rowData[\'status\'] === \'inactive\' ? \'\' : \' checked="checked"\';
                            return sprintf(\'<span>%3$s</span>&nbsp;<input type="checkbox" name="status[%1$s]" id="status_%1$s" value="%1$s"%2$s />\', $rowData[\'id_button\'], $isChecked, $txt[$rowData[\'status\']], $rowData[\'status\']);
                        '),
                        'class' => 'centertext',
                    ),
Title: Re: [ADDON] Ultimate Menu
Post by: tino on June 27, 2018, 07:58:15 pm
Here is an example of the first one, I think it should work...

Code: [Select]
'data' => array (
    function ($rowData ) use ( $txt ) {
        return $txt[$rowData['type'] . '_link'];
    }
),
Title: Re: [ADDON] Ultimate Menu
Post by: Mrs. Chaos on June 27, 2018, 09:43:40 pm
My second:

Code: [Select]
'data' => array (
    function ($rowData ) use ( $txt ) {

    // Don\'t show the stub name if we can find the parent name
    $check = common_um_name($rowData['parent']);
    $name = !empty($check) ? $check : $rowData['parent'];

    return $txt['mboards_order_' . $rowData['position']] . ' ' . ucwords($name);
    }
),


and my third:

Code: [Select]
'data' => array (
     function ($rowData ) use ( $txt ) {

    $isChecked = $rowData['status'] === 'inactive' ? '' : ' checked="checked"';
     return sprintf(\'<span>%3$s</span>&nbsp;<input type="checkbox" name="status[%1$s]" id="status_%1$s" value="%1$s"%2$s />', $rowData['id_button'], $isChecked, $txt[$rowData['status']], $rowData['status']);
     }
    'class' => 'centertext',
),

Are they correct?

After the upload the Ultimate Menu pages are not shown, but this new error message:
syntax error, unexpected 'if' (T_IF)

The error protocol says this:
Exception: syntax error, unexpected 'if' (T_IF)
line 11

Line 11 is the second here:
Code: [Select]
create_function
    if (!defined('ELK'))
die('No access...');
Title: Re: [ADDON] Ultimate Menu
Post by: tino on June 27, 2018, 11:05:41 pm
They look correct, not sure how that create_function got in the top of your file? That’s causing the error.

The \ on the third one just after the sprintf also shouldn’t be there.
Title: Re: [ADDON] Ultimate Menu
Post by: ahrasis on June 28, 2018, 06:52:06 am
I hope I remember to look into this when I am home. Now I need to do some shopping.
Title: Re: [ADDON] Ultimate Menu
Post by: Mrs. Chaos on June 28, 2018, 12:01:21 pm
I removed the slash and also the "create_function".
Now there's an error message for line 218:
syntax error, unexpected ''class'' (T_CONSTANT_ENCAPSED_STRING), expecting ')'

Line 218 is the penultimate:  'class' => 'centertext',

Code: [Select]
'data' => array (
    function ($rowData ) use ( $txt ) {

    $isChecked = $rowData['status'] === 'inactive' ? '' : ' checked="checked"';
    return sprintf('<span>%3$s</span>&nbsp;<input type="checkbox" name="status[%1$s]" id="status_%1$s" value="%1$s"%2$s />', $rowData['id_button'], $isChecked, $txt[$rowData['status']], $rowData['status']);
    }
    'class' => 'centertext',
),
Title: Re: [ADDON] Ultimate Menu
Post by: tino on June 28, 2018, 07:35:05 pm
Think you need a , after the closing }

Sorry I can’t test atm only on my phone until the weekend now.
Title: Re: [ADDON] Ultimate Menu
Post by: Mrs. Chaos on June 28, 2018, 09:04:28 pm
Yes, it was the missing  ,  .
The error messages are now gone. Thank you!  :)

However, as I have seen, in the ACP in the list of the menu buttons, the entries under "Button Type" and "Button Position" are gone, too. Something like "external link" and "after Forum". That's also now when I create a new link/button.
But the links in the forum menu are working and so that's not bad.
Title: Re: [ADDON] Ultimate Menu
Post by: tino on June 28, 2018, 09:12:52 pm
It might be that the $txt isn’t defined as a global until it was called.

Try putting global $txt; at the start of each function ( not the ones you just created , but the existing ones )

It might be showing something in the error log on Elkarte about $txt being undefined if this is the issue.
Title: Re: [ADDON] Ultimate Menu
Post by: Mrs. Chaos on June 28, 2018, 09:40:31 pm
The error log is empty...
Title: Re: [ADDON] Ultimate Menu
Post by: Mrs. Chaos on June 29, 2018, 11:52:45 am
I didn't manage that with the global $txt; . Either I did something wrong while writing or I inserted it in the wrong places. Or both together...
Would you please take another look at it and tell me what exactly I need to insert where or what I have to change?
You can take your time, it's not hurry!

Attached is the current page.
Title: Re: [ADDON] Ultimate Menu
Post by: tino on June 29, 2018, 07:00:13 pm
Try the attached, I've not tested it but I think that was the mistake... I removed the first 'function' => when I shouldn't off.
Title: Re: [ADDON] Ultimate Menu
Post by: Mrs. Chaos on June 29, 2018, 07:52:24 pm
Yes, that was the mistake. All errors are corrected now and the missing information is displayed again!
Thank you for your great help!!!  :)