I am a newbie in yii and i want to know whether is there any method which can set a value of a variable whenever any page loads. Eg-(Its just an example) if there is a variable $count . Now i want to set the value of the $count as 3 whenever any page loads . I have heard about onBeginRequest() but do not know how to do it. ANy help will be appreciated
Asked
Active
Viewed 121 times
0
Let me see
- 5,063
- 9
- 34
- 47
-
1beforeRender or beforeAction may help you achieve this i think.. – Coder anonymous Nov 29 '13 at 10:29
-
Is the count variable dynamic or static value ?? – Ninad Nov 29 '13 at 11:28
1 Answers
1
In the application life cycle, onBeginRequest is raised right BEFORE the application processes the request. So you can do anything you want before your pages are loaded.
See this link if you want to know how to use onBeginRequest
How to use events in Yii