CodeIgniter子目录中的视图

Class

public function load($page = 'resources')
{
    if ( ! file_exists(APPPATH.'views/resources/'.$page.'.php'))
    {
        // Whoops, we don't have a page for that!
        show_404();
    }

    $data['title'] = ucfirst($page); // Capitalize the first letter

    $this->load->view('templates/header', $data);
    $this->load->view('resources/multiplication'.$page, $data);
    $this->load->view('templates/footer', $data);

}

Directory

-Application
--views
---resources
----multiplication
-----selector.php

I'm trying to load selector.php with localhost://resources/load/selector but it just shows a 404. I can't get the classes to work with sub directories in the view folders.

If I move selector into /resources, it loads no problem. How can I get load method to load selector.php?

</div>

That's because before you load your view you have a condition to load the 404 error. You should remove that condition or edit it to your real path:

public function load($page = 'resources')
    {
         if ( ! file_exists(APPPATH.'views/resources/multiplication/'.$page.'.php')) //Just added the multiplication to make it the right path
    {
            // Whoops, we don't have a page for that!
            show_404();
    }

    $data['title'] = ucfirst($page); // Capitalize the first letter

    $this->load->view('templates/header', $data);
    $this->load->view('resources/multiplication'.$page, $data);
    $this->load->view('templates/footer', $data);

    }

You are simply missing a / before $page in both circumstances:

public function load($page = 'resources')
    {
         if ( ! file_exists(APPPATH.'views/resources/multiplication/'.$page.'.php')) //Just added the multiplication to make it the right path
    {
            // Whoops, we don't have a page for that!
            show_404();
    }

    $data['title'] = ucfirst($page); // Capitalize the first letter

    $this->load->view('templates/header', $data);
    $this->load->view('resources/multiplication/'.$page, $data);
    $this->load->view('templates/footer', $data);

    }

FYI as Eduardo alluded to, the show_404() isn't really necessary and is actually more confusing. In CI, if a view doesn't exist it will tell you that it doesn't exist. However, if you want to avoid such a message what you are doing is fine.