e107inc / e107

e107 Bootstrap CMS (Content Management System) v2 with PHP, MySQL, HTML5, jQuery and Twitter Bootstrap. Issue Discussion Room: https://gitter.im/e107inc/e107
https://e107.org
GNU General Public License v3.0
322 stars 214 forks source link

Deprecated e107::getmenu()->isLoaded ? #4385

Closed rica-carv closed 3 years ago

rica-carv commented 3 years ago

In current stable version, the method e107::getmenu()->isLoaded is available and populated, but with latest github files, it's almost empty, and therefore the ->isLoaded doesn't work.

Is this intended or is it a bug???

Jimmi08 commented 3 years ago

@rica-carv I am almost sure, that CaMeRon will want to know where you use this method. F.e. in plugin shortcodes (local, global).

CaMer0n commented 3 years ago

@rica-carv It's not deprecated. Menus are now loaded in HEADERF instead of class2.php. Jimmi is correct. Where are you running it from?

rica-carv commented 3 years ago

@CaMer0n I'm running it from a plugin that depends of a it's own menu to be loaded. I know, there's currently only one plugin that uses this function: Featurebox....

So, at runtime, how can i check if my menu is loaded or not? I'm currently checking for it at the plugin main file code start, before fetching data, run templates, etc., because the main plugin depends of it's own menu.... So, @Jimmi08 currently it's checked before everything else, even before running HEADERF (that it's at the code bottom)....

imagem

rica-carv commented 3 years ago

Thaks you all, got it running....

CaMer0n commented 3 years ago

Good to hear @rica-carv ! Where did you move the check?

rica-carv commented 3 years ago

Good to hear @rica-carv ! Where did you move the check?

@CaMer0n I didn't move it. It stayed where it was originally, because i need it at the begining of the code, so that if the menu is not there, the page displays only a error... So, i ended up moving HEADERFto before the check.... and had to put a few if then below......

CaMer0n commented 3 years ago

okay, thank you!

rica-carv commented 3 years ago

Well, i spoke too soon....

If i use the code like this:

if (!(e107::getmenu()->isLoaded("philcat"))) {
    $msg->warning(PHCAT_L05);
    if (ADMIN == TRUE) {
       $msg->error(PHCAT_L06);
    }

require_once(HEADERF);

i got the msg displayed, but the menu is not detected.... If i use it like this:

require_once(HEADERF);

if (!(e107::getmenu()->isLoaded("philcat"))) {
    $msg->warning(PHCAT_L05);
    if (ADMIN == TRUE) {
       $msg->error(PHCAT_L06);
    }

the menu is detected but the msg is not displayed.....

CaMer0n commented 3 years ago

@rica-carv This should solve it:

echo $mes->render(); 

I still don't know where you're getting the method warning() from?

rica-carv commented 3 years ago

I still don't know where you're getting the method warning() from?

Err, @CaMer0n , i've copyed it from another plugin, long time ago, but indeed, suposedly it shouldn't work, but it does.... I have no code to change the $msg method, but it works.... Also, the error()shouldn't also work, but it does, and it's currently also in another core plugins....

P.S.: Thanks for the render() tip, it works now... Re-Closing...

CaMer0n commented 3 years ago

Glad to hear it's working. I would be careful with those methods. Is it possible you have old files in your installation? (Run File Inspector? )

rica-carv commented 3 years ago

Glad to hear it's working. I would be careful with those methods. Is it possible you have old files in your installation? (Run File Inspector? )

No, @CaMer0n , i'm working on a fresh v2 install, so there's no old files, maybe just my plugin, but i'm cleanning it up to bring it to v2 standards...

CaMer0n commented 3 years ago

Sounds good :+1:

Moc commented 3 years ago

@rica-carv please see https://e107.org/developer-manual/classes-and-methods/alerts

I strongly recommend not to use other methods (like warning()). They may work (for whatever reason) but are not the standard and may stop functioning at any time.

rica-carv commented 3 years ago

@Moc Working on it. Thanks for the tip.... I don't get it why it's working, since my code doesn't change anything on the message handler....