Welcome Guest, Not a member yet? Register   Sign In
href to display page
#5

Just wanted to thank you for replying - I got the tutorial setup working. Just to explain why I got confused...

The first part tells me to add:

Code:
<?php
class Pages extends CI_Controller {

        public function view($page = 'home')
        {
        }
}

The 'adding logic to the controller' said to add the following:

Code:
public function view($page = 'home')
{
        if ( ! file_exists(APPPATH.'views/pages/'.$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('pages/'.$page, $data);
        $this->load->view('templates/footer', $data);
}

In true newbie fashion I've put 2 + 2 together and got 6 with this: 

Code:
public function view($page = 'home')

{

public function view($page = 'home')
{
        if ( ! file_exists(APPPATH.'views/pages/'.$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('pages/'.$page, $data);
        $this->load->view('templates/footer', $data);
}

}


Apologies if I come across annoyed, as simple as this is to do I was getting frustrated.

Thank you for the help
Reply


Messages In This Thread
href to display page - by dmorgan20 - 11-17-2019, 08:00 AM
RE: href to display page - by dave friend - 11-17-2019, 01:33 PM
RE: href to display page - by dmorgan20 - 11-18-2019, 10:34 AM
RE: href to display page - by dave friend - 11-18-2019, 12:23 PM
RE: href to display page - by dmorgan20 - 11-18-2019, 01:59 PM



Theme © iAndrew 2016 - Forum software by © MyBB