Welcome Guest, Not a member yet? Register   Sign In
Setting a menu item to "selected"
#7

[eluser]Exeneva[/eluser]
[quote author="Eric Barnes" date="1276746962"]I created a build_link helper for this:

Code:
/**
* Build Link Helper
*
* Usuage
* <?php build_link(site_url('categories'), lang('lang_cats'), 'categories'); ?>
*
* @param    string  - Link Url
* @param    string     - Title
* @param    string    - Name must back uri segment
* @param    string    - Class
*
* @return    string
*/
function build_link($link = '', $title = '', $name = '', $class = '', $echo = TRUE)
{
    $CI =& get_instance();
    $page = $this->CI->uri->segment(2);
    
    if ($page == strtolower($name))
    {
        $att['class'] = 'active';
    }
    
    $link = '<a href="'.$link.'" title="'.$title.'" class="'.$class.'">'.$title.'</a>';
    
    if ($echo)
    {
        echo $link;
    }
    else
    {
        return $link;
    }
}
[/quote]

I hate to revive an old thread, but I'm quite intrigued by this solution.

Since it's a helper, would it have to be added to the CI core as an extension? I'm a little confused as to where this is implemented.


Messages In This Thread
Setting a menu item to "selected" - by El Forum - 06-16-2010, 02:16 PM
Setting a menu item to "selected" - by El Forum - 06-16-2010, 02:38 PM
Setting a menu item to "selected" - by El Forum - 06-16-2010, 02:39 PM
Setting a menu item to "selected" - by El Forum - 06-16-2010, 08:56 PM
Setting a menu item to "selected" - by El Forum - 06-25-2010, 03:04 PM
Setting a menu item to "selected" - by El Forum - 08-14-2011, 05:52 PM
Setting a menu item to "selected" - by El Forum - 04-14-2012, 03:25 PM
Setting a menu item to "selected" - by El Forum - 04-14-2012, 05:01 PM
Setting a menu item to "selected" - by El Forum - 04-14-2012, 05:20 PM



Theme © iAndrew 2016 - Forum software by © MyBB