Doug Molineux
Doug Molineux

Reputation: 12431

CodeIgniter Views

Ok I have adopted a CodeIgniter Setup,

My route.php in config looks like this:

$route['default_controller'] = "development";

My development.php controller looks like this:

class Development extends Controller
{

function Development() {

parent::Controller();

}

public function Index() {

    $this->load->view('index');

}
function show() {

    $this->load->view('show');

}
}

When I go to the root folder, in my browser, it does load the index.php view, I want to make a link to show.php which is also in my Views dir. the URL I'm using is eg: my.server/test/codeigniter/ but when I go to my.server/test/codeigniter/show my show.php doesn't load. Am I doing this correctly?

I should mention I've tried public function show() also and it doesn't work, also I have no .htaccess file in the directory

Any advice would help!

Upvotes: 0

Views: 587

Answers (3)

Nooha Haris
Nooha Haris

Reputation: 41

You can set it in routes.php as below:

$route['show']='development/show';

Upvotes: 0

mhitza
mhitza

Reputation: 5715

Two rules are enough in your .htaccess file:

# check if the requested resource is not an existing file
RewriteCond %{REQUEST_FILENAME} !-f

# rewrite internally to index.php
RewriteRule ^(.*)$ index.php [QSA,L]

Mod_rewrite and AllowOverride All assumed enabled.

Upvotes: 1

kevtrout
kevtrout

Reputation: 4984

Ken Struys comment on your question is correct. The default controller status you give a controller means that controller and the index function will load if you go to my.server/test.

Other than that, you need to include index.php/controller_name/function_name to get to your controller functions.

Unless that is, you implement some fancy .htaccess url rewriting, which I can't help you with.

Upvotes: 0

Related Questions