Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Navigation - Active link class
#1
Hi,

where are the files / lines to change the code, in which the navigation adds the 'class="current"' attribute to the active navigationpoint? I would like to cut it out there and paste it in the <a href=""> Attribute for the navigationpoints!

Sorry, cannot find it on my own...

Thanks and happy easter-days!
I LOVE this place. Thanks for making such a great piece of code!
Reply
#2
soy Wrote:where are the files / lines to change the code, in which the navigation adds the 'class="current"' attribute to the active navigationpoint? I would like to cut it out there and paste it in the <a href=""> Attribute for the navigationpoints!

Why would you want to do that?
Any CSS rule a.current can also be defined as li.current a.
Changing code in GetSimple or a plugin is not a good idea as it makes updating to a new version much harder.

And if you still want to do it, just search for get_navigation or current in the /admin folder and below.
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply
#3
If you wish to have your own menu style, create a file "functions.php" in your template directory.

add this code inside (from theme_functions.php in admin/inc) :
Code:
function get_navigation($currentpage) {

    $menu = '';

    global $pagesArray;
    
    $pagesSorted = subval_sort($pagesArray,'menuOrder');
    if (count($pagesSorted) != 0) {
        foreach ($pagesSorted as $page) {
            $sel = ''; $classes = '';
            $url_nav = $page['url'];
            
            if ($page['menuStatus'] == 'Y') {
                if ("$currentpage" == "$url_nav") { $classes = "current ". $page['parent'] ." ". $url_nav; } else { $classes = trim($page['parent'] ." ". $url_nav); }
                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";
            }
        }
        
    }
    
    echo exec_filter('menuitems',$menu);
}
Don't forget to add this line at the beginning of this file :
Code:
<?php if(!defined('IN_GS')){ die('you cannot load this page directly.'); }
and finish file with :
Code:
?>
rename the function like : get_my_navigation

edit it as you want.

in your theme you have to call this new function instead of get-navigation.
Reply
#4
Oh my god, thanks a lot mvlcek, you are totally right. I do not know why I did not came across with that solution...

Thanks, too, didou. I will keep this in mind for other projects and custom settings!

You guys are great! Thanks (:
I LOVE this place. Thanks for making such a great piece of code!
Reply




Users browsing this thread: 1 Guest(s)