• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Newbie - Setup and URL Questions

#1
[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.

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

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

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

#4
[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?

#5
[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?


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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