S
S
Sergey2016-08-16 19:52:19
Yii
Sergey, 2016-08-16 19:52:19

How to determine the current id in Yii2?

Yii::$app->user->identity->id;
So you can determine the id of the current user
And how can you, for example, determine the id of the current page?
Yii::$app->objects->identity->id;
doesn't work like that

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Timofeev, 2016-08-20
@webinar

The page has no id.
If you mean the id of some model from which you form the page, then you can either find it in the url parameters (if you pass one).
Or maybe you mean id for action?
You can place this code in the view:
and see everything that you can get, there are module and controller id, etc.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question