GetSimple Support Forum

Full Version: How to change menu active label?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I installed MagicForest Theme instead of Lucid. 

The original menu active label was "current active" like this:

Code:
<li class="index current active">
     <a href="xxx">Home</a>    
</li>

but the new theme need "uk-active" label, where can I replace it?

Thank you very much.
I found the file, it's admin/inc/theme_functions.php:
================================================
if ($page['menuStatus'] == 'Y') {
$parentClass = !empty($page['parent']) ? $classPrefix.$page['parent'] . " " : "";
$classes = trim( $parentClass.$classPrefix.$url_nav);
if ("$currentpage" == "$url_nav") $classes .= " current active";
if ($page['menu'] == '') { $page['menu'] = $page['title']; }
if ($page['title'] == '') { $page['title'] = $page['menu']; }
$menu .= '<li class="'. $classes .'"><a href="'. find_url($page['url'],$page['parent']) . '" title="'. encode_quotes(cl($page['title'])) .'">'.strip_decode($page['menu']).'</a></li>'."\n";
}
Instead of editing GS core files, I suggest you copy the whole get_navigation function to your theme's functions.php file (create it if it doesn't exist) with a different name (e.g. "my_get_navigation"), make the "uk-active" change there, and use this new function in your template. This way you will be able to upgrade GS without having to edit theme-functions.php again.
get_navigation($currentpage,$classPrefix = "") lets you add prefixes, but it does not appear that I added it to the active classes....
hmm
(2018-02-01, 05:21:25)Carlos Wrote: [ rel="nofollow" -> ]Instead of editing GS core files, I suggest you copy the whole get_navigation function to your theme's functions.php file (create it if it doesn't exist) with a different name (e.g. "my_get_navigation"), make the "uk-active" change there, and use this new function in your template. This way you will be able to upgrade GS without having to edit theme-functions.php again.

Thank you. I moved this function to theme's functions.php file.
Is it possible to strip the li generating from the function?
You can just edit your custom function and make the changes in the line $menu .= '<li class= ... </li>'."\n";

Another way would be adding this to your theme's functions.php:
Code:
add_filter('menuitems', 'custom_menuitems_markup');

function custom_menuitems_markup($menu) {
  $menu = str_replace(array('<li','</li>'), array('<span','</span>'), $menu);
  return $menu;
}

With this, you could still use get_navigation in your template, but it would output <span> tags instead of <li>'s
Thanks Carlos.

Apparently this line has to be present on top of functions.php , not just for security, but otherwise it will post everything in that file as text in the top of the webpage.

PHP Code:
<?php if(!defined('IN_GS')){ die('you cannot load this page directly.'); } 

The wiki page about this doesn't mention this.
If I'm not mistaken, if(!defined('IN_GS') ... is recommended but not really required - only if the file has some code logic (function calls, etc.), but not if it just contains function definitions.

Anyway the file must begin with <?php or else it will output anything before that as text, as you say.
(2018-02-25, 19:07:38)Carlos Wrote: [ rel="nofollow" -> ]Anyway the file must begin with <?php or else it will output anything before that as text, as you say.

Oh off course! Totally forgot about that, that's the reason..