Welcome Guest, Not a member yet? Register   Sign In
Include a menu on every page? use url helper in a class?
#18

[eluser]NateL[/eluser]
OK - I got it working.

Code:
$a =    array
                (
                    'home'      => '/home',
                    'about'     => '/about',
                    'portfolio'  => '/portfolio',
                    'contact'   => '/contact'
                );
    foreach($a as $title => $url):
        $toggle = strpos($url, $this->uri->uri_string) ? '<li class="active">' : '<li>';
        echo $toggle.anchor($url, $title)."</li>\n";
    endforeach;

I switched the positions of $url and $this->uri->uri_string. I figured that out by reading up on strpos in the PHP Manual and looking at this code example:

Code:
$mystring = 'abc';
$findme   = 'a';
$pos = strpos($mystring, $findme);
Oddly enough, it does not work if I remove the slash in my $a array: /about works. about does not.

Quote:I think that it is the anchor that requires the class toggle to change color and not the link.
All 3 parameters of the anchor helper are optional.


Messages In This Thread
Include a menu on every page? use url helper in a class? - by El Forum - 10-31-2009, 09:18 AM



Theme © iAndrew 2016 - Forum software by © MyBB