default $id

I have set the defaultController in main.php and defaultAction in the controller. However I cannot find how to set the default $id in the controller. Can anyone help?

Hi,

As I like to say, I’m pretty new in yii framework world. So, my question is maybe not relevant, but what do you call a default $id?

No, but you can easily implement it. What exactly do you intend to do?

Sorry, the question may have been a little vague.

When the site loads with no variables given in the URL (eg. www.somesite.com/) I have defined the default controller and action to call using the method described in my first post. As most models will relate directly to a database table I thought there might also be a way to set the default table.id to be used also.

I could be mistaken.

As the default action in my site is actionShow() which in turn calls loadContent() I have changed the line:


public function loadContent($id=null)

to:


public function loadContent($id=1)

I thought there might be a better practice way of doing this.

Thanks for the replies.

I think there is no real need to implement this in the core. Your approach resolves the problem very well.