Topic Closed
juergen
1.5K Posts
64.5K Downloads
16 Plugins

Works but is hackish:

$eval = \gp\tool::function_exists('eval');
if( $eval ){
  $template_file = file_exists($page->theme_dir.'/'.$page->theme_color.'/template.php')
    ? $page->theme_dir.'/'.$page->theme_color.'/template.php'
    : $page->theme_dir.'/template.php';
  if( file_exists($template_file) ){
    $template_php = file_get_contents($template_file);
    preg_match('#\$GP_MENU_CLASSES\s(.*?)\s*\);#is', $template_php, $matches);
    if( count($matches) ){
      eval($matches[0]);
    }
    msg('$GP_MENU_CLASSES = ' . pre($GP_MENU_CLASSES) );
  }
}

Is there any better way to get $GP_MENU_CLASSES from within a plugin gadget (without the need of editing the template.php)?

Thx!

7 years ago#9150

Josh S.
2K Posts
311K Downloads
16 Themes
18 Plugins

Hmm, so global $GP_MENU_CLASSES doesn't work in your situation?

 

7 years ago#9156

juergen
1.5K Posts
64.5K Downloads
16 Plugins

global $GP_MENU_CLASSES doesn't work in your situation?

Nope, gives NULL.

7 years ago#9157

juergen
1.5K Posts
64.5K Downloads
16 Plugins
Should actually work - I wonder where it get's 'nulled'
7 years ago#9164

Josh S.
2K Posts
311K Downloads
16 Themes
18 Plugins
I think I know what's happening, I should be able to check the code in a few hours


7 years ago#9165

juergen
1.5K Posts
64.5K Downloads
16 Plugins

Thanks! A mini-addon for testing: TestGMC.zip

7 years ago#9167

Josh S.
2K Posts
311K Downloads
16 Themes
18 Plugins

Here's what's happening.

Gadget content is generated before it's actually added to a webpage. ( Generated in PrepGadgetContent() which is called by gpOutput::GetHead() )

Themes that I have made place the definition of $GP_MENU_CLASSES after the call to gpOutput::GetHead().

So, for $GP_MENU_CLASSES to be available, it should really be set in the settings.php file instead of the template.php file of a theme.

7 years ago#9168

juergen
1.5K Posts
64.5K Downloads
16 Plugins

I already thought it must be something like that. Hmm.
Actually it would have been cool to know the exact menu classes on PHP side in the gadget, but on the other hand I at least know if $GP_MENU_ELEMENTS is 'BootstrapMenu" or not, which is a key puzzle piece. I'll probably get the other pieces togehter with some 'forensics'. Although regexing the values out of template.php and using eval() works it's unreliable (e.g. Suhosin etc.) and not exactly performance-wise. Funnily the most efficient way was checking the theme name against a handwritten LUT.

Thanks for checking!

7 years ago#9169

Topic Closed

 

News

elFinder 2.1.50 in Upcoming Release
12/28/2019

A new release for Typesetter is in the works with a lot of improvements including the ... Read More

Typesetter 5.1
8/12/2017

Typesetter 5.1 is now available for download. 5.1 includes bug fixes, UI/UX improvements, ... Read More

More News

Log In

  Register