Topic Closed
juergen
1.4K Posts
49.7K Downloads
16 Plugins
design, web development & visual effects

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!

3 years ago#9150

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

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

 

3 years ago#9156

juergen
1.4K Posts
49.7K Downloads
16 Plugins
design, web development & visual effects

global $GP_MENU_CLASSES doesn't work in your situation?

Nope, gives NULL.

3 years ago#9157

juergen
1.4K Posts
49.7K Downloads
16 Plugins
design, web development & visual effects
Should actually work - I wonder where it get's 'nulled'
3 years ago#9164

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


3 years ago#9165

juergen
1.4K Posts
49.7K Downloads
16 Plugins
design, web development & visual effects

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

3 years ago#9167

Josh S.
2K Posts
262K 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.

3 years ago#9168

juergen
1.4K Posts
49.7K Downloads
16 Plugins
design, web development & visual effects

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!

3 years ago#9169

Topic Closed

 

News

Typesetter 5.1
8/12/2017

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

Over 8 Times Faster Than Wordpress
5/3/2016

We've known for a long time that Typesetter is fast. It's something we take pride ... Read More

More News

creisi productions

Dienstleistungen von creisi productions, Luzern (Schweiz): * Konzeption, Planung und Erstellung Ihres Internet-Auftritts * Betreuung und Aktualisierung/Pflege Ihrer Website * ...

Find out more about our Provider Spotlight

Log In

  Register