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.

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

报告相同问题?

悬赏问题

  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算