• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Issue loading function

#1
Hey!

I recently asked about loading a controller within another and after a while realized I was jumping the gun a little (Grateful for the help Smile )! I trying to do the basic route but getting a '404' page not found error code through creating an anchor. Here is the code:

class notifications extends CI_Controller {

    public function index(){
        global $data;
        $data['meta_title'] = "Notification";
        if(empty($_SESSION['w3_user_id'])) {
            redirect('', 'refresh');
        }
        else{
            $data['sidebar'] = 'sidebar_left';
            $data['rightbar'] = 'rightbar';
            $data['page_content'] = 'notification';
            $data['navigation'] = 'home';
            $this->load->model('friend_model');
            $this->load->library('database','session','form_validation','email');
            $this->load->helper('url');
            $data['notification'] = $this->friend_model->get_all_notification();
            $this->load->view('template', $data);
        }
        
    }
    
                public function notify()
    {    
        $this->load->view('notification');        
    }

}

What do I add or subtract within this code to make things work? Thank you for the help!!!


Heart Heart ,
Mekaboo
Reply

#2
"Make things work"... what about this isn't working for you - you didn't say.

Off the top, your controller name should be UCfirst, i.e. Notifications.

Second, please use the [ code ] php code here [ / code ] tags for code readability. (after removing the spaces in the tags)
Reply

#3
And why are you using a global $data variable array?

you can simple using CI's this->load->vars($data) and it is global to all views.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply

#4
(08-14-2019, 10:41 PM)ciadmin Wrote: "Make things work"... what about this isn't working for you - you didn't say.

Off the top, your controller name should be UCfirst, i.e. Notifications.

Second, please use the [ code ] php code here [ / code ] tags for code readability. (after removing the spaces in the tags)

So sorry about that and will make correction within code Heart
Reply

#5
(08-15-2019, 09:10 AM)InsiteFX Wrote: And why are you using a global $data variable array?

you can simple using CI's this->load->vars($data) and it is global to all views.

I was using code that was already created  but notice thing about it wasnt working. Will add this and see if it helps Heart
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.