Yii Framework Forum: Defaultcontroller Ignored? - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Defaultcontroller Ignored? Rate Topic: -----

#1 User is offline   Trejder 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,257
  • Joined: 06-October 10
  • Location:Southern Poland

Posted 11 April 2013 - 08:12 AM

I'm doing an extensive / change / update of my old application and at some point I've noticed, that links pointing to default controller (MainController in my case) actions are just not working.

Even though I have a definition in app's configuration:


return array
(
	'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',
	'name'=>'Name',
    'defaultController'=>'main',

whenever I click a link pointing to for example contact.html (which should invoke contactAction from MainController) I'm getting 404 and Yii error "Unable to resolve the request "contact"". I have to add controller, even though it is default one, to get such links working.

I'm kind of lost, because this is first time (first Yii app), I'm running it such strange situation. Anyone got any idea, what can be wrong?
Proud Cookbook author, though still learning powerful Yii! :] See my generic profile for more information. Cheers!
0

#2 User is offline   Trejder 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,257
  • Joined: 06-October 10
  • Location:Southern Poland

Posted 15 April 2013 - 02:47 AM

Though I had no reply to my topic, I add extra info, which maybe led someone to help me.

It seems, that at some stage, all default-behaviour in my application has failed.

Right now, I've noticed, that even default actions in a controllers are not invoked, and instead results in 404.

Though I have indexAction() defined in my controller, though it is actually copied from auto-generated application and though it claim (in a comment) that: "This is the default 'index' action that is invoked when an action is not explicitly requested by users", I can't use this or any other controller without action part in route, because I'm getting 404 instead of executing default action.

What can be wrong? Can this be somehow related to CUrlManager (though I haven't touched its code -- just tested that rules part is 100% the same as in auto-generated path)?

EDIT: Actually, it turns out, that everything fails with 404, if there is no controller and / or action exactly specified. Even login/logout functions fails, because -- for some reason -- Yii::app()->homeUrl and Yii::app()->user->returnUrl contains either empty string or just the application root folder, assuming to execute default controller and action, which fails in my case.
Proud Cookbook author, though still learning powerful Yii! :] See my generic profile for more information. Cheers!
0

#3 User is offline   Jorgee 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 58
  • Joined: 22-March 13

Posted 15 April 2013 - 08:30 AM

Post your controller actions names and your config. The default action works good, you must be missing something.

Default action is defined in Controllers, default Controller in config/main.php-.

class TestController extends CController
{
public $defaultAction = 'test';
public function actionTest()
{
// your default action page
}
}

Maybe it's a problem with your rewrite rules.... If you have an app from scratch it works good... but there are no .html ending requests.
0

#4 User is offline   Trejder 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,257
  • Joined: 06-October 10
  • Location:Southern Poland

Posted 15 April 2013 - 01:45 PM

Thank you for your attempt to help and a bunch of information, that I'm already aware of.

I've been able to identify, that possible source of my problems is in implementing Hyphenation of routes in URL management, when useStrictParsing is set to TRUE (as advised in mentioned example). Setting this parameter to FALSE (default value for CUrlManager) seems to be solving the problem and mentioned implementation also seems to be working fine without it.

So, I think, that would be all for now.
Proud Cookbook author, though still learning powerful Yii! :] See my generic profile for more information. Cheers!
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users