Yii Framework Forum: How can I use a 'action' name as a parameter? - Yii Framework Forum

Jump to content

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

How can I use a 'action' name as a parameter? Rate Topic: -----

#1 User is offline   LotusH 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 80
  • Joined: 06-May 11
  • Location:China

Posted 08 May 2011 - 01:26 PM

I want to know how to use an action name as a parameter 'cause i want my URL like this pattern:'/item/[item_number]' where 'item_number' can be used as a parameter so that i can access database with this number.
Any one who can help me? THKS!
0

#2 User is offline   LotusH 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 80
  • Joined: 06-May 11
  • Location:China

Posted 08 May 2011 - 02:15 PM

I found the function 'createAction()', but i don't know how to use it.
    public function actionCreate($category, $language='en')
    {
        $category=(int)$category;
}

what should i write after that $category line to make the effect like
return array(
            'edit'=>'application.controllers.post.UpdateAction',
        );

in 'actions' function? How can i change 'edit' to $category?
0

#3 User is offline   LotusH 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 80
  • Joined: 06-May 11
  • Location:China

Posted 08 May 2011 - 03:16 PM

No one knows about this?
Using the createAction doesn't work, cause it can only get parameters from Get['$'].
What i really need is changing the Action name to what the user inputs but those 'actions' will all use one real action.
I think it's an url problem, and we can solve it by changing CUrlManager. The question is how ....
0

#4 User is offline   softark 

  • Keep It Simple
  • Yii
  • Group: Moderators
  • Posts: 2,047
  • Joined: 16-February 11
  • Location:Japan

Posted 08 May 2011 - 07:03 PM

I think you can get what you want just by configuring the urlManager, with your [item_number] being remained as a GET parameter to a certain action.

Take a look at the guide. URL management
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