I’m building a custom CMenu like this, that I use instead of standard “/layouts/column2.php”. I’ve read different articles and discussions online, but I need a little help.
What is the best way to get id of “active” model. I can easily get it with Php instruction, using $_GET[‘id’], but I don’t like it, because I’m pretty sure there are better ways with Yii. Additionally, in future, url like “index.php?r=item/update&id=12” could be “item/update/12”, so I have to set it pretty well.
I would to show some menu options, based on view. If I’m watching item list I would to show the “New item” option only, because id isn’t set. When I’m watching one item (id is set), selected from the preview list, I would have “new”, “edit” and every operation I can do on this item. Any idea?
I would to create a new operation like "Join item", ie join actual item (id=12) with another one that could be selected. How can I build this operation, step by step? Can you link me some article?
Hi. I’m talking about “\protected\views\layouts\my_menu.php”. I have to correct your post, because $_POST of course doesn’t work. $_GET is what we need.
However, $model->id doesn’t work too, because I’m calling $model in this layout script and I get error Undefined variable: model . How can I get this id, not using $_GET, but using Yii instruments?
I’ll explain point 3 later. I would solve point 1, first.
My controlloer, contains public function actionCreate(), public function actionIpdate(), public function actionDelete(), public function actionIndex(). I can create a new record, edit it, delete it. Really standard.
What I have to do is another action to link items (records). So I would have another menu (lets say "Join") and associate an action like actionJoin() to create another record in another table (M to N relation). I hope you understand. However I would like to have some link with articles and/or discussions to read.