[SOLVED] how to set something like this: http://localhost/test/<model>/<action>?id=1 as startpage of the website?

Hey guys,

I could just find ways via the defaultController, where you can just set an actual action as startpage, but is it also possible to set an action and give it an id or something like that?

http://localhost/test/<model>/<action>?id=1

Thanks in advance for your help,

Mayjestic

Did you try action parameter binding with default arguments?





class FooController extends CController

{

  public function actionList( $id=1 )

  {

    [...]

  }

}



That’s what I did right now … but how can I set an “actionView” as startpage? … he just doesn’t accept this … I also tried using strictParsing … here it works if I e.g. say:


'test' => 'entry/view',

but this:


'defaultController' => 'entry/view',

doesn’t work because he awaits a controller … not an action. :frowning:

You need to separately set the default action for the controller.

You can do this directly in the controller itself:




class EntryController extends CController

{

  public function init()

  {

    parent::init();

    $this->defaultAction = 'view';

  }

}



Or in your application configuration using the controllerMap property:




// This is the main Web application configuration. Any writable

// CWebApplication properties can be configured here.

return array(

  [...]


  'controllerMap' => array(

    'entry' => array(

      'class' => 'path.to.EntryController',

      'defaultAction' => 'view',

    ),

  ),

 

  [...]

);



Thanks so much Ben! It works now :slight_smile:

You’re welcome! :)