1. 取得網站根目錄 ( 例如:/seminar2014 )
<?php echo Yii::app()->request->baseUrl; ?>
2. 取得網站目前網址 ( 例如:/seminar2014/site/index )
<?php echo Yii::app()->request->requestUri; ?>
ChouAndy 發表在 痞客邦 留言(0) 人氣(292)
raw: the attribute value will not be changed at all.
text: the attribute value will be HTML-encoded when rendering.
ntext: the formatNtext method will be called to format the attribute value as a HTML-encoded plain text with newlines converted as the HTML <br /> tags.
html: the attribute value will be purified and then returned.
date: the formatDate method will be called to format the attribute value as a date.
time: the formatTime method will be called to format the attribute value as a time.
datetime: the formatDatetime method will be called to format the attribute value as a date with time.
boolean: the formatBoolean method will be called to format the attribute value as a boolean display.
number: the formatNumber method will be called to format the attribute value as a number display.
email: the formatEmail method will be called to format the attribute value as a mailto link.
image: the formatImage method will be called to format the attribute value as an image tag where the attribute value is the image URL.
url: the formatUrl method will be called to format the attribute value as a hyperlink where the attribute value is the URL.
ChouAndy 發表在 痞客邦 留言(0) 人氣(13)
想要在一開始搜尋資料的時候,就載入關聯的資料表資料,可以使用下面方法:
1. 確認好 Model 裡的 relations()
public function relations(){
return array(
'creator' => array(self::BELONGS_TO, 'User', 'creator_id'),
);
}
ChouAndy 發表在 痞客邦 留言(0) 人氣(71)
例如: Module 名稱為 admin,只要在 AdminModule.php 內,新增以下程式碼即可:
public $layout = '/layouts/column2';
至於在 column2 內 載入 main.php 只要使用 /layouts/main 即可。
ChouAndy 發表在 痞客邦 留言(0) 人氣(46)
1. 修改 protected\config\main.php
return array(
...
'language' => 'zh_tw',
...
);
ChouAndy 發表在 痞客邦 留言(0) 人氣(133)
手動安裝
1. 下載檔案 yii-fancybox
2. 將目錄 assets 及檔案 FancyBox.php 放到目錄 protected/extensions/fancybox 底下
ChouAndy 發表在 痞客邦 留言(0) 人氣(81)
覺得 Yii 的網址不夠美觀嗎??
可以照著下面的方法,來讓網址更簡潔美觀唷!! 去掉 index.php 和 僅顯示路徑名稱。
1. 在 webapp 下新增一個 .htaccess 檔,並將以下內容複製貼上:
RewriteEngine on
# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# otherwise forward it to index.php
RewriteRule . index.php
ChouAndy 發表在 痞客邦 留言(0) 人氣(186)
本批次檔除了新增 Yii webapp 外,還會新增 Yii 在 git 需要的 .gitignore 檔案,內容如下:
@ECHO OFF
ECHO ★ Auto Create Yii Framework Webapp By ChouAndy ★
ECHO.
@SET /P VAR1=請輸入 Yii Webapp 名稱:
@if not exist %VAR1% goto 1
@goto end
:1
md %VAR1%
:end
ECHO # Ignore section> %VAR1%\.gitignore
ECHO /assets/*>> %VAR1%\.gitignore
ECHO /protected/runtime/*>> %VAR1%\.gitignore
ECHO.>> %VAR1%\.gitignore
ECHO # Except section>> %VAR1%\.gitignore
ECHO !/assets/empty>> %VAR1%\.gitignore
SET /P=!/protected/runtime/empty> %VAR1%\.gitignore
ECHO.
CALL yii\framework\yiic.bat webapp %VAR1%
ChouAndy 發表在 痞客邦 留言(0) 人氣(60)
1. 新增 PHP 資料夾至系統變數裡的 Path 變數
( Win7: 開始工具列 > 電腦右鍵內容 > 進階系統設定 > 環境變數 > Path )
2. 打開 Windows 的命令提示字元
3. 進入 Yii Framework Root 的 framework 資料夾
ChouAndy 發表在 痞客邦 留言(0) 人氣(75)