[SOLVED] Add class to existing function
Posted: Tue Apr 10, 2018 4:24 pm
Hi,
For me to be able to use Bootstrap 4.0 among other things I need to add classes to the navigation <li>s.
To do this I need to change the menu() function from this:
to this
But I don't want to change the index.php file.
Is there a way for me to do this using a function in functions.php that overrides the menu() function in index.php?
Or is there any other way to do this without touching the index.php file?
Thanks in advance for your help.
Cheers.
For me to be able to use Bootstrap 4.0 among other things I need to add classes to the navigation <li>s.
To do this I need to change the menu() function from this:
Code: Select all
public static function menu()
{
$output = '';
foreach (wCMS::get('config', 'menuItems') as $key => $value) {
if ($value->visibility == "hide") {
continue;
}
$output .= '<li' . (wCMS::$currentPage === $value->slug ? ' class="active"' : '') . '><a href="' . wCMS::url($value->slug) . '">' . $value->name . '</a></li>';
}
return wCMS::hook('menu', $output)[0];
}
Code: Select all
public static function menu()
{
$output = '';
foreach (wCMS::get('config', 'menuItems') as $key => $value) {
if ($value->visibility == "hide") {
continue;
}
$output .= '<li class="nav-item nav-link' . (wCMS::$currentPage === $value->slug ? ' active"' : '"') . '><a href="' . wCMS::url($value->slug) . '">' . $value->name . '</a></li>';
}
return wCMS::hook('menu', $output)[0];
}
Is there a way for me to do this using a function in functions.php that overrides the menu() function in index.php?
Or is there any other way to do this without touching the index.php file?
Thanks in advance for your help.
Cheers.