2012-03-17 120 views
0

所以基本上,我有两个关于kohana网址的快速问题。Kohana链接相关问题

1)使用Kohana附带的默认.htaccess,在加载另一个视图后,它将.php添加到索引文件。所以,例如,如果我加载产品视图,它看起来像这样 - http://mysite.com/index.php/products,但我很喜欢它看起来http://mysite.com/index/products

的.htaccess代码 -

# 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)我有两个controlles - 家庭和产品。首页是默认页面,但是当我加载产品页面时,如上所述,它显示没有设计。两个页面布局都是相同的(文件不同,我只是复制,而我正在测试它是否正常)。

控制器代码 -

<?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); 
    } 


} 

它加载只是一个平面的html代码,我不知道如果我真的这样做正确。

我真的希望你能帮我找到解决方案,因为我查了一些Kohana的教程,看来我做得很好,在文档中也是这样。我从CodeIgniter来到Kohana,这是一个更大的文档,并且更容易理解,但据我发现,很多程序员说Kohana比CodeIgniter更好。

非常感谢您阅读本文;)!

回答

0

2),你应该设置你的模板控制器,试试这个: Kohana template $content variable shows nothing 然后从模板控制器扩展记录和内容变量绑定到模板文件中的视图和回声的内容。

对于第一个问题,我只是建议你在bootstrap.php的init方法中将你的index_file设置为false,并且如果你非常需要的话,创建索引控制器。