Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
QUESTION How to change menu active label?
#1
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.
Reply
#2
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";
}
Reply
#3
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.
Reply
#4
get_navigation($currentpage,$classPrefix = "") lets you add prefixes, but it does not appear that I added it to the active classes....
hmm
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply
#5
(2018-02-01, 05:21:25)Carlos Wrote: 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.
Reply
#6
Is it possible to strip the li generating from the function?
Reply
#7
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
Reply
#8
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.
Reply
#9
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.
Reply
#10
(2018-02-25, 19:07:38)Carlos Wrote: 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..
Reply




Users browsing this thread: 1 Guest(s)