您可以创建一个包装控制器访问专门的功能和使用你的路线,利用该URL的
例子:yoursite.com/helper/geo/citiesNearZip/90210
class helperController extends CI_Controller {
public function __construct()
{
parent::__construct();
$this->load->helper($this->uri->segment(1)); // geo helper in this example
if($this->uri->segment(2))
{
$helper_method = $this->uri->segment(2);
}
else
{
show_404();
return false;
}
// check if helper has function named after segment 2, function citiesNearZip($zip) in this example...
if(function_exists($helper_method)
{
// Execute function with provided uri params, xss filter, secure, etc...
// You would also want to grab all the remaining uri params and pass them as
// arguments to your helper function
$helper_method();
}
}
}
正确的,我可以空包装控制器,并能访问。我知道这个。谢谢。 –
也许这是最好的方法... –
这是一个非常糟糕的主意。你不能错误地处理你的url调用 - 如果“geo”是一个不存在的帮助器,代码将会简单地爆炸。这是一个“整洁的黑客”,但编码错误 – jmadsen