Welcome Guest, Not a member yet? Register   Sign In
homepage set... moving on? newb help
#1

[eluser]Unknown[/eluser]
so, i have my homepage and loading the templates. now, i'm trying to get a second page (about us) working. not sure how to go about doing that... here is my controller thus far (as of right now, i'm not using a database)

Code:
class Home extends Controller {

function Home(){
        parent::Controller();    
    }
    function index(){
    $data["title"] = "home page title...";
    $data["description"] = "home page description...";
    $this->load->vars($data);
    $this->load->view('include/header');
    $this->load->view('layout/home');
    $this->load->view('include/footer');
    }
}

so i assume i would use the same controller and just add to it. i basically want an "about us" page that uses a different template (i understand how to set the template using the view loader). also confused about the url structure needed to access this page. ideally i just want "index.php/about"

if someone could break this down for me i would GREATLY appreciate it.
#2

[eluser]danmontgomery[/eluser]
The url structure is:

Quote:http://www.mydomain.tld/{controller}/{me...parameters}...

Where the default method is index(). So,

Quote:http://www.mydomain.tld/home

Will point to the Home controller, and the index method. To go to about, you would have a method in the Home controller called about(), and the url would be:

Quote:http://www.mydomain.tld/home/about

If you want to remove home from that url, you'd need to use custom routing. You can read about routing (and the above) at http://ellislab.com/codeigniter/user-gui...uting.html
#3

[eluser]Bart v B[/eluser]
So, the second parameter you can make a new function:

Code:
class Home extends Controller {

function __construct(){
        parent::Controller();    
    }

    function index(){
    $data["title"] = "home page title...";
    $data["description"] = "home page description...";
    $this->load->vars($data);
    $this->load->view('include/header');
    $this->load->view('layout/home');
    $this->load->view('include/footer');
    }

    function aboute()
    {
    
     $data["title"] = "aboute title...";
     $data["description"] = "home page description aboute...";
     $this->load->vars($data);
     $this->load->view('include/header');
     $this->load->view('layout/home');
     $this->load->view('include/footer');

    }
}




Theme © iAndrew 2016 - Forum software by © MyBB