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.

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

报告相同问题?

悬赏问题

  • ¥50 三种调度算法报错 有实例
  • ¥15 关于#python#的问题,请各位专家解答!
  • ¥200 询问:python实现大地主题正反算的程序设计,有偿
  • ¥15 smptlib使用465端口发送邮件失败
  • ¥200 总是报错,能帮助用python实现程序实现高斯正反算吗?有偿
  • ¥15 对于squad数据集的基于bert模型的微调
  • ¥15 为什么我运行这个网络会出现以下报错?CRNN神经网络
  • ¥20 steam下载游戏占用内存
  • ¥15 CST保存项目时失败
  • ¥20 java在应用程序里获取不到扬声器设备