如何根据Code igniter中的用户类型自定义导航

I am building web application with 4 type of users and starting from top level(Admin) to lower level(end-user) , access rights for specific tab will be eliminated.

I have consider idea of using html helper but in this case I am not able to assign class and attributes to my li elements.

$this->load->helper('html');

$list = array(
            'level 1', 
            'level 2', 
            'level 3',
            'level 4'
            );

$attributes = array(
                    'class' => 'boldlist',
                    'id'    => 'mylist'
                    );

echo ul($list, $attributes);

let me know , how can I add attributes to list item.

Above mentioned code will generate this.

<ul class="boldlist" id="mylist">
  <li>level 1</li>
  <li>level 2</li>
  <li>level 3</li>
  <li>level 4</li>
</ul>

You could do it manually:

$ul[0]['list'] = array(
    'level 1' => array('class' => 'test'), 
    'level 2',
    'level 3',
    'level 4'
);

$ul[0]['attributes'] = array(
    'class' => 'boldlist',
    'id'    => 'mylist'
);

foreach ($ul as $_ul) {
    echo '<ul';
    // add attributes
    foreach ($_ul['attributes'] as $_ulak => $_ulav) {
        echo ' '.$_ulak.'="'.$_ulav.'"';
    }
    echo '>';

    // add list items
    foreach ($_ul['list'] as $_ullk => $_ullv) {
        if (is_array($_ullv)) {
            echo '<li';
            // add list attributes
            foreach ($_ullv as $_ullvk => $_ullvv) {
                echo ' ' . $_ullvk . '="' . $_ullvv . '"';
            }
            echo '>';
            echo $_ullk;
        } else {
            echo '<li>' . $_ullk;
        }
        echo '</li>';
    }
    echo '</ul>';
}

You can't do this with the HtmlHelper class that CodeIgniter provides:

So you should create your code manually or hack the helper to have this functionality and of course you can create a request (or pull-request) on their github account:

https://github.com/bcit-ci/CodeIgniter