简体   繁体   English

重定向URL-Codeigniter

[英]Redirecting URL - Codeigniter

I needed help in redirecting my page depending on your current page. 根据您当前的页面,我需要帮助重定向页面。

So basically, 所以基本上

I have a navigation bar with a notification dropdown and in that dropdown, I have the option to accept and delete. 我有一个带有通知下拉菜单的导航栏,在该下拉菜单中,我可以选择接受和删除。

Let's say I'm in my profile page and I want to click delete from the notification, I wan't to just stay in the profile page. 假设我在我的个人资料页面中,我想单击通知中的删除,而我不想只停留在个人资料页面中。 And if I'm in the settings page I click delete, it will still stay in the settings page. 如果我在“设置”页面中,请单击“删除”,它仍将保留在“设置”页面中。

Any idea how to do this? 任何想法如何做到这一点?

This is what Ive done so far. 到目前为止,这是我所做的。

function delete_notif(){
    $id = $this->uri->segment(3);
    $pid = $this->uri->segment(4);
     $this->admin_model->delete($id, $pid);

    $profile = 'profile';
    $settings = 'settings';


    if($id = $profile && $id != $projects) {
        redirect('manager/profile');
    } else if ($id != $settings && $id = $projects) {
        redirect('manager/all_projects');
    }
}

You have incorrect compare in "if" statement - there should be "==" instead of "=". 您在“ if”语句中比较不正确-应该有“ ==”而不是“ =“。 But I think it will be better to write it like that: 但我认为最好这样写:

function delete_notif(){
    $id = $this->uri->segment(3);
    $pid = $this->uri->segment(4);
    $this->admin_model->delete($id, $pid);

    switch($id) {
        case 'profile':
            redirect('manager/profile');
            break;
        case 'settings':
            redirect('manager/all_projects');
            break;
        default:
            redirect('manager/profile');
            break;
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM