Welcome Guest, Not a member yet? Register   Sign In
Learning CI and very confused on URL's
#1

[eluser]ChrisF79[/eluser]
I'm stuck on something seemingly simple. I have created in my controller:

Code:
class Site extends CI_Controller {

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

function index() {

  // Load The Model To Pull Categories
  $this->load->model('site_model');    
  $this->load->view('index', $data);
}

function property() {
  $this->load->model('property_model');  
  $data['title'] = 'Test Title';
  $this->load->view('property', $data);
}

}

I have my .htaccess getting rid of the index.php part. So, I thought I could go to mysite.com/property/ and it would load the property view but that is giving me a 404. Any ideas as to what I'm doing wrong?
#2

[eluser]weboap[/eluser]
mysite.com/site/property
#3

[eluser]ChrisF79[/eluser]
[quote author="weboap" date="1338054298"]mysite.com/site/property[/quote]
Wow, that was very easy. Unfortunately, I want it to be mysite.com/property/ so is it common to have two classes within my site.php controller file? What's the proper way of doing it?
#4

[eluser]CroNiX[/eluser]
Create a route, however, if you are not very familiar with how CI works, this might cause issues with other things because once you use routes it changes how CI works and you have to route everything.
#5

[eluser]ChrisF79[/eluser]
Reading the URI documentation, it sounds like they want me to make a new controller file for everything. This is a real estate site in the making and the idea is that this would be the page that displays the properties. So is it unreasonable to make a controller for the page that displays the individual properties, a controller for the index page, etc?
#6

[eluser]Aken[/eluser]
You make new controller files wherever you need to. You can make an entire site in one single controller if you route it properly. Or you separate controllers if you have a lot of code and want things separated to make life easier. It's up to you.




Theme © iAndrew 2016 - Forum software by © MyBB