错误:重定向到登录Croogo,cakephp中的每个控制器操作

时间:2014-03-17 18:57:11

标签: cakephp cakephp-2.0 croogo

下午好,

我目前正在使用croogno版本2.0.0.dev.2,我正在尝试添加自己的名为itemscontroller的控制器(不是插件)来显示项目。我遇到了两个问题: 1.每当我尝试对我的项目进行分页时,它总是将我重定向到登录名。登录后,我被重定向到我要前往的页面,但如果我尝试任何其他链接,它会要求登录。问题出在哪里可以解决?

  1. 在我的分页中,按钮链接包含额外的网址,这是不必要的。例如,该链接变为http://localhost/myapp/items/page:2/page:2?%2Fitems=,而不仅仅是http://localhost/myapp/items/page:2/
  2. 有人可以帮我解决这些问题吗?

1 个答案:

答案 0 :(得分:0)

我建议尝试通过烘焙工具创建MVC文件,并将差异与手写文件进行比较。

举个例子:

$ Console/cake bake model Item

Welcome to CakePHP v2.5.0-dev Console
---------------------------------------------------------------
App : croogo-app
Path: /home/rachman/work/personal/deploy/croogo-app/
---------------------------------------------------------------
---------------------------------------------------------------
You have more than one set of templates installed.
Please choose the template set you wish to use:
---------------------------------------------------------------
1. croogo
2. default
Which bake theme would you like to use? (1/2) 
[1] > 1

Baking model class for Item...

Creating file /home/rachman/work/personal/deploy/croogo-app/Model/Item.php
Wrote `/home/rachman/work/personal/deploy/croogo-app/Model/Item.php`

Baking test fixture for Item...

Creating file /home/rachman/work/personal/deploy/croogo-app/Test/Fixture/ItemFixture.php
Wrote `/home/rachman/work/personal/deploy/croogo-app/Test/Fixture/ItemFixture.php`
Bake is detecting possible fixtures...

Baking test case for Item Model ...

Creating file /home/rachman/work/personal/deploy/croogo-app/Test/Case/Model/ItemTest.php
Wrote `/home/rachman/work/personal/deploy/croogo-app/Test/Case/Model/ItemTest.php`

$ Console/cake bake controller Items --public

Welcome to CakePHP v2.5.0-dev Console
---------------------------------------------------------------
App : croogo-app
Path: /home/rachman/work/personal/deploy/croogo-app/
---------------------------------------------------------------
Baking basic crud methods for Items
---------------------------------------------------------------
You have more than one set of templates installed.
Please choose the template set you wish to use:
---------------------------------------------------------------
1. croogo
2. default
Which bake theme would you like to use? (1/2) 
[1] > 1

Baking controller class for Items...

Creating file /home/rachman/work/personal/deploy/croogo-app/Controller/ItemsController.php
Wrote `/home/rachman/work/personal/deploy/croogo-app/Controller/ItemsController.php`
Bake is detecting possible fixtures...

Baking test case for Items Controller ...

Creating file /home/rachman/work/personal/deploy/croogo-app/Test/Case/Controller/ItemsControllerTest.php
Wrote `/home/rachman/work/personal/deploy/croogo-app/Test/Case/Controller/ItemsControllerTest.php`
$ Console/cake bake view Items 

Welcome to CakePHP v2.5.0-dev Console
---------------------------------------------------------------
App : croogo-app
Path: /home/rachman/work/personal/deploy/croogo-app/
---------------------------------------------------------------
---------------------------------------------------------------
You have more than one set of templates installed.
Please choose the template set you wish to use:
---------------------------------------------------------------
1. croogo
2. default
Which bake theme would you like to use? (1/2) 
[1] > 2

Baking `index` view file...

Creating file /home/rachman/work/personal/deploy/croogo-app/View/Items/index.ctp
Wrote `/home/rachman/work/personal/deploy/croogo-app/View/Items/index.ctp`

Baking `view` view file...

Creating file /home/rachman/work/personal/deploy/croogo-app/View/Items/view.ctp
Wrote `/home/rachman/work/personal/deploy/croogo-app/View/Items/view.ctp`

Baking `add` view file...

Creating file /home/rachman/work/personal/deploy/croogo-app/View/Items/add.ctp
Wrote `/home/rachman/work/personal/deploy/croogo-app/View/Items/add.ctp`

Baking `edit` view file...

Creating file /home/rachman/work/personal/deploy/croogo-app/View/Items/edit.ctp
Wrote `/home/rachman/work/personal/deploy/croogo-app/View/Items/edit.ctp`

请注意,在烘焙视图时,我选择了默认模板。

使用这些生成的文件,我似乎没有问题添加新项目并对记录进行分页。

相关问题