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.
所有路线。我正在尝试从谷歌的很多sugesstions并没有任何帮助,我写了一些因为我不能更新这个tobic因为里面的代码太多了。
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?
任何sugestions?
Ps. still can't update this topic :/ Wtf must be more characters in tekst than in code ? this is my first asc on *. So sorry for this ;)
PS。仍无法更新此主题:/ Wtf必须是tekst中的字符多于代码中的字符吗?这是我在*上的第一个asc。很抱歉这个;)
1 个解决方案
#1
3
You have two catch all routes (default
and user
) in your Bootstrap file. These two routes do exactly the same.
您有两个捕获Bootstrap文件中的所有路由(默认和用户)。这两条路线完全相同。
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.
此外,由于这些路由是全部捕获并且路由的顺序很重要,这意味着如果catch所有路由是第一个匹配所有URL。
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
.
另一件事,通常都是不好的做法。尝试创建特定于您的控制器的路由。
#1
3
You have two catch all routes (default
and user
) in your Bootstrap file. These two routes do exactly the same.
您有两个捕获Bootstrap文件中的所有路由(默认和用户)。这两条路线完全相同。
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.
此外,由于这些路由是全部捕获并且路由的顺序很重要,这意味着如果catch所有路由是第一个匹配所有URL。
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
.
另一件事,通常都是不好的做法。尝试创建特定于您的控制器的路由。