douyong1885 2013-11-08 09:48
浏览 23
已采纳

子文件夹中的Kohana 3.3控制器

I have controllers

--controllers
  --Administrator
    -Base.php
    -Admin.php (extend Base.php)
-controller1.php
-controller2.php
-etc

And my route looks like this

    Route::set('administrator', 'Administrator(/<controller>(/<action>(/<id>)))')
->defaults(array(
    'directory' => 'Administrator',
    'controller' => 'base',
    'action'     => 'index',
));

Try to load this controller and i get message Not found

What's wrong?

UPDATE!

class Controller_Administrator_Base extends Controller_Template {

    public $template = 'panel/index';

    public function action_index(){
        echo 'kupakonia';
    }
} // End Welcome

All routes. I was trying alot of sugesstions from google and nothing helps, and I write something becouse i cant update this tobic becouse is too much code inside.

Still can't update.

Route::set('default', '(<controller>(/<action>(/<id>)))')
->defaults(array(
    'controller' => 'read',
    'action'     => 'index',
));
Route::set('user', '(<controller>(/<action>(/<id>)))')
->defaults(array(
    'controller' => 'user',
    'action'     => 'index',
));

Route::set('administrator', 'administrator(/<controller>(/<action>(/<id>)))')
->defaults(array(
    'directory' => 'Administrator',
    'controller' => 'base',
    'action'     => 'index',
));

Any sugestions?

Ps. still can't update this topic :/ Wtf must be more characters in tekst than in code ? this is my first asc on stackoverflow. So sorry for this ;)

  • 写回答

1条回答 默认 最新

  • duanchi4184 2013-11-08 10:35
    关注

    You have two catch all routes (default and user) in your Bootstrap file. These two routes do exactly the same.

    Also, since these routes are catch all and the order of the routes matter, this means if the catch all route is the first it will match all URLs.

    Try this:

    Route::set('administrator', 'administrator(/<controller>(/<action>(/<id>)))')
    ->defaults(array(
        'directory' => 'Administrator',
        'controller' => 'base',
        'action'     => 'index',
    ));
    
    Route::set('default', '(<controller>(/<action>(/<id>)))')
     ->defaults(array(
        'controller' => 'read',
        'action'     => 'index',
    ));
    

    Another thing, it is usually bad practice to have a catch all route. Try to create routes specific for your Controllers.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?