Common paths in Yii

Source: Internet
Author: User
Common paths in Yii (goto)


Http://hi.baidu.com/design231/item/e4fea9db57d76fc71a72b4bc
Call the YII framework in Jquery:yii::app ()->clientscript->registercorescript (' jquery ');

Framework/web/js/source JS, where registercorescriptkey called files can be viewed in the framework/web/js/packages.php list

Get the ID of the current controller in view method: Yii::app ()->getcontroller ()->id;

Get the ID method of the current action in view: Yii::app ()->getcontroller ()->getaction ()->id;

YII Get IP Address: Yii::app ()->request->userhostaddress;

Yii Judgment Submission Method: Yii::app ()->request->ispostrequest

Get current domain name: Yii::app ()->request->hostinfo

Get the physical path to the proteced directory: Yii::app ()->basepath;

Get the URL of the previous page to return: Yii::app ()->request->urlreferrer;

Get current Url:yii::app ()->request->url;

Get current Home Url:yii::app ()->homeurl

Get current return Url:yii::app ()->user->returnurl

Project path: DirName (Yii::app ()->basepath)



One: The YII framework has defined namespace constants
System: Point to the YII framework directory; Yii\framework
Zii: Point to zii Library directory; Yii\framework\zii
Application: Point to the application base directory; protected\
Webroot: Point to the directory containing the entry script file; .\
Ext: Point to the directory containing all third-party extensions; \protected\extensions

Usage: Yii::getpathofalias (' Webroot ')

Two: {full URL}: Get the current complete path
Yii::getframeworkpath (): YII Framework Path

Three:

Insert meta Information Yii::app ()->clientscript->registermetatag (' keywords ', ' keywords ');   Yii::app ()->clientscript->registermetatag (' description ', ' some descriptions '); Yii::app ()->clientscript->registermetatag (' author ', ' author ');

Example:

<link rel= "Alternate" type= "Application/rss+xml" href= "http://www.dreamdu.com/feed/"/>

Expressed as:

Yii::app ()->clientscript->registerlinktag (' alternate ', ' Application/rss+xml ', $this->createurl ('/feed ') );

Add a CSS file 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 ');

Gets the ID method of the current controller in view Yii::app ()->getcontroller ()->id;

Get the ID method of the current action in view: Yii::app ()->getcontroller ()->getaction ()->id;

Yii Gets the IP address Yii::app ()->request->userhostaddress;

Yii Judgment Submission Method Yii::app ()->request->ispostrequest

Get current domain name: Yii::app ()->request->hostinfo

Get the physical path to the proteced directory Yii::app ()->basepath;

Get the URL of the previous page to return to Yii::app ()->request->urlreferrer;

Get current URL

Yii::app ()->request->url;

Get the current home URL

Yii::app ()->homeurl

Get the current return URL

Yii::app ()->user->returnurl

Project path

DirName (Yii::app ()->basepath)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.