为什么不在我调用函数时加载视图? 笨

I have a problem in codeigniter. I call a funtion in controller Articles from the view.

<li><a href="index.php/articles/Category/1" ><?php echo $item['CATEGORY'] ?></a></li>

The function

   function getCategories() {

    $this->db->select('ID_CAT,CATEGORY');
    $this->db->from('CATEGORY');
    $query = $this->db->get();

    if ($query->num_rows() > 0) {
        return $query->result_array();
    } else {
        return FALSE;
    }
    }

 function Category($id_cat) {
    if (!$id_cat) {
        $id_cat = 0;
    }

    $this->load->model('graf/home_model');
    $data = array();
    $data['categories'] = $this->home_model->getCategories();
    $filtro_cat = $id_cat;
    $data['article'] = $this->home_model->getArticles($filtro_cat);
    $this->load->view('graf/articles', $data, TRUE);

   }

home_model

function getArticles($filtro_cat) {

    $this->db->select('*');
    $this->db->from('ARTICLES');
    if ($filtro_cat != 0) {
        $this->db->where("ID_CAT=".$filtro_cat);
    }
    $query = $this->db->get();

    if ($query->num_rows() > 0) {
        return $query->result_array();
    } else {
        return FALSE;
    }
}

When i select the button the url changes to http://localhost/Graf/index.php/articles/Category/1 but does not load http://localhost/Graf/index.php/articles/

Why?

When you set third argument of load->view() to true it returns string value and does not output anything

Try changing:

$this->load->view('graf/articles', $data, TRUE);

to

$this->load->view('graf/articles', $data);

set the routes.php in folder config, add this code;

$route['articles/Category/(.*)'] = 'articles/$1';

and change the link

<li><a href="<?php echo site_url('index.php/articles/'.$item['ID_CAT']); ?>" ><?php echo $item['CATEGORY'] ?></a></li>

and change your controller to this

$this->load->view('graf/articles', $data);