Summary of common Yii path methods. Summary of common path methods in Yii Framework. Add a CSS file or JavaScript file in the controller: Yii: app ()-clientScript-registerCss Yii common path method summary
Summary of some common path methods in the Yii Framework.
Add a CSS or JavaScript file to the controller:
Yii::app()->clientScript->registerCssFile(Yii::app()->baseUrl.'/css/my.css'); Yii::app()->clientScript->registerScriptFile(Yii::app()->baseUrl.'/css/my.js');
module->assetsUrl; ?>/css/main.css
Call the js of framework/web/js/source in the YII framework. the file called by registerCoreScript key can be viewed in the framework/web/js/packages. php list:
Yii::app()->clientScript->registerCoreScript('jquery');
Obtain the ID method of the current controller in view:
Yii::app()->getController()->id;
Obtain the ID of the current action in the view:
Yii::app()->getController()->getAction()->id;
Yii get IP address
Yii::app()->request->userHostAddress;
Yii determines whether the submission method is a post request
Yii::app()->request->isPostRequest
Yii determines whether it is an ajax request
Yii::app()->request->isAjaxRequest
Get the current domain name:
Yii::app()->request->hostInfo
Obtain the physical path of the proteced directory.
YII::app()->basePath;
Returns the url of the previous page.
Yii::app()->request->urlReferrer;
Get the current url
Yii::app()->request->url;
Get the current home url
Yii::app()->homeUrl
Returns the current return url.
Yii::app()->user->returnUrl
Project path
dirname(Yii::app()->BasePath)
If you have a directory that is commonly used in some classes or files, you can define a path alias at the top of main. php. the alias can be translated into the corresponding path.
Yii::getPathOfAlias('webroot')
You can add one configuration to multiple arrays in main. php.
Articles you may be interested in
- Yii rules common verification rules memo
- Summary of using database transactions in Yii
- Yii View (output) the SQL statement executed on the current page
- Yii database addition, modification, and deletion operations summary
- How to configure the default controller and action in the yii Framework
- Yii controller action parameter binding
- Yii action methods and techniques
- Yii database query operation summary
Summary of some common path methods in the policyii framework. Add a CSS file or JavaScript file in the controller: Yii: app ()-clientScript-registerCss...