codeigniter 中的 _remap 函数

发布于 2025-01-06 07:43:16 字数 363 浏览 3 评论 0原文

我试图在 codeigniter 中使用重映射功能,但它不起作用。我有一个名为 submit_me 的方法,我会在 URL 中的 submit-me 中对其进行转换。我读到我可以使用 _remap 函数,但不幸的是我无法使用它。

public function _remap($method)
{
    if($method == 'submit-me')
    {
        $this->submit_me();
    }
    else 
    {
        $this->index();
    }
}

这是正确的用法吗?

I'm trying to use remap function in codeigniter but it doesn't work. I have a method called submit_me and I would transform it in submit-me in the URL. I read I can use _remap function but unfortunately I wasn't able to use it.

public function _remap($method)
{
    if($method == 'submit-me')
    {
        $this->submit_me();
    }
    else 
    {
        $this->index();
    }
}

this is the correct use of it?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

眼角的笑意。 2025-01-13 07:43:16

_remap() 用于调用类别。

示例:

我正在为一家电视制作公司建立一个网站。需要一个部分来展示他们的作品。这些作品分为以下几类:纪实片、戏剧片、事件片、儿童片和合拍片。

控制器名称后面的 url 段会自动作为参数传递,

function _remap($method){   

    if($method == 'current' || 
       $method == 'factual' || 
       $method == 'kids' || 
       $method == 'drama' || 
       $method == 'events' || 
       $method == 'co')
    {

因为我使用的是 URI 语言类,所以我在这里使用了 segment(4),这会在控制器之前添加一个额外的段,所以通常 segment(3) 就可以了

        $this->genre($method, $this->uri->segment(4)); 
    }else{
        $this->index();
    }

}

function index(){

    redirect('productions/current');

} 

_remap() is used for a call a category.

Example :

I’m building a website for a TV production company. A section was needed to showcase their productions. These productions fall into categories: factual, drama, events, kids and co-productions.

the segment of the url after the controller name is automatically passed as the argument

function _remap($method){   

    if($method == 'current' || 
       $method == 'factual' || 
       $method == 'kids' || 
       $method == 'drama' || 
       $method == 'events' || 
       $method == 'co')
    {

I use segment(4) here as I'm using the URI language class, which adds an extra segment before the controller, so usually segment(3) would be OK

        $this->genre($method, $this->uri->segment(4)); 
    }else{
        $this->index();
    }

}

function index(){

    redirect('productions/current');

} 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文