删除代码点火器 CMS 中的函数名称 URL



当数据传入控制器时,数据和函数名称传入URL

localhost/project/course/Web-Development

上面的示例course是控制器的函数名称但删除它并传递此 URL

localhost/project/Web-Development

使用重映射函数我们可以解决这个问题

控制器中的代码

public function _remap($method, $params = array())
{
    if ($method == 'autocomplete') {
        return call_user_func_array(array($this, $method), $params);
    } else {
        $methodcall = $this->M_tl_admin->Validate_Web($method);
        if ($methodcall == 'course') //***course is your function name***
            return call_user_func_array(array($this, $methodcall), array($method));
        }
}

模型中的代码

    public function Validate_Web($alias)
{
    $res = $this->db->get_where('category', array('ctg_url' => $alias))->result_array();//category is table name and ctg_url is data pass in URL(Web-Development)
    if(count($res)>0)
         return 'course';
}

您可以使用路由要素隐藏函数名称。

https://www.codeigniter.com/user_guide/general/routing.html

$route['product/:any'] = 'project/product_look

最新更新