CodeIgniter Forums
Newbie - Setup and URL Questions - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Newbie - Setup and URL Questions (/showthread.php?tid=26759)



Newbie - Setup and URL Questions - El Forum - 01-22-2010

[eluser]joshdrew[/eluser]
I set up Codeigniter..left everything pretty much default. I was able to create a few pages and registration forms and so far so goo. My question is regarding urls and templates.

I have a mysite.php controller file. this performs the necessary functions to pass variables into my view pages to get the right content for my template.

ex:
Code:
function about() {
        $data['main_content'] = 'about';
        $data['page_title'] = 'Welcome to Diary 90';
        $this->load->view('template', $data);
    }

I have a template file in views that pulls everything together

Code:
$this->load->view('includes/header');

$this->load->view($main_content);

$this->load->view('includes/footer');

I then added a default controller called "mysite" to the routes config.

if I go to http://mysite.com I get the index page. Great.
if I go to http://mysite.com/mysite/about I get the about page. Ok.

Questions
1. How can i get the about page by just going to http://mysite.com/about. I can do that WITHOUT templates but not with one. I must have something set up incorrectly.

2. If I wanted a "members" area like http://mysite.com/members/index how do I set that up? do I create a subdirectory in the controllers dir called members?

Thanks.


Newbie - Setup and URL Questions - El Forum - 01-22-2010

[eluser]rogierb[/eluser]
1: Routes
2: Routes or a controller called members.

Read up on Routes in the userguide, wiki and this forum


Newbie - Setup and URL Questions - El Forum - 01-22-2010

[eluser]joshdrew[/eluser]
Great. Thanks for the quick reply.


Newbie - Setup and URL Questions - El Forum - 01-22-2010

[eluser]joshdrew[/eluser]
I read up on routes a bit and figured out how to eliminate the "controller" from the url.

so what I stated before about mysite.com/mysite/about is now mysite.com/about.

The other question is still open a bit. I found this post
http://ellislab.com/forums/viewthread/119780/
...looks like what I am trying to accomplish but no dice.

i currently have
Code:
+controllers
  +members
    -member.php
  -mysite.php

where mysite.php is the default controller. I would like member.php to be the members controller.

so if I go to mysite.com/members/index or mysite.com/members/welcome the member.php would take care of the pages. right now i keep getting 404. I added members to the routes.config but no dice either.

Am I on the right path?


Newbie - Setup and URL Questions - El Forum - 01-22-2010

[eluser]joshdrew[/eluser]
Ahhhh...the default_controller is the default for the whole site, including subdirectories.

i had member/member.php and it was never finding it once i changed it to member/mysite.php which is the default all is well.

am i approaching this correctly?