So basically, I have two fast questions about kohana urls.
1) With default .htaccess that comes with Kohana, after loading another view, it add’s .php to index file. So, for example if I load product view, it looks something like this – http://mysite.com/index.php/products , but I would love it to look http://mysite.com/index/products .
.htaccess code –
# Turn on URL rewriting
RewriteEngine On
# Installation directory
RewriteBase /
# Protect hidden files from being viewed
<Files .*>
Order Deny,Allow
Deny From All
</Files>
# Protect application and system files from being viewed
RewriteRule ^(?:application|modules|system)\b.* index.php/$0 [L]
# Allow any files or directories that exist to be displayed directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Rewrite all other URLs to index.php/URL
RewriteRule .* index.php/$0 [PT]
2) I have two controlles – home and products. Home is default page, but when I load products page, as described above, it shows without design. Both page layouts are same (files are different, I just copied, and I’m testing if it’s working).
Controller code –
<?php defined('SYSPATH') or die('No direct script access.');
class Controller_Records extends Controller {
public function action_index()
{
$records_view = View::factory('products');
$records = $records_view->render();
$this->response->body($records);
}
}
It loads just a plane html code, I’m not sure if I’m really doing it correctly.
I really hope you will help me find out solution for this, since I checked some Kohana tutorials and it seems I’m doing it fine, also in documentation it’s the same thing. I’ve came to Kohana from CodeIgniter, which was a little bit bigger documentation, and easier to understood, but as far as I found out, many programmers say that Kohana are alot better than CodeIgniter.
Thank you very much for reading this ;)!
2) you should setup your template controller, try this:
Kohana template $content variable shows nothing
And then extends Records from template controller and bind content variable to the view and echo content in template file.
And for the first question, I’d simply advice you to set your index_file to false in init method in bootstrap.php and create index controller if you need it so much.