if (Yii::app()-> user-> getIsGuest()) {
die('must login');
} else {
die('login');
}
CSS ~ set height 100%
html {
height: 100%;
}
body {
margin: 0;
padding: 0;
height: 100%;
}
#content {
background: #EEE;
border-left: 1px solid #000;
border-right: 1px solid #000;
padding: 0 20px 0 20px;
margin: auto;
font: 1.5em arial, verdana, sans-serif;
width: 960px;
min-height: 100%;
}
reference
http://www.tutwow.com/htmlcss/quick-tip-css-100-height/
height: 100%;
}
body {
margin: 0;
padding: 0;
height: 100%;
}
#content {
background: #EEE;
border-left: 1px solid #000;
border-right: 1px solid #000;
padding: 0 20px 0 20px;
margin: auto;
font: 1.5em arial, verdana, sans-serif;
width: 960px;
min-height: 100%;
}
reference
http://www.tutwow.com/htmlcss/quick-tip-css-100-height/
yii ~ urlManager rules example
之前做產品頁面我的網址都是透過apache設定成
product/xbox360
或是
product/ps3
作法是
RewriteRule ^product/([a-zA-Z0-9_-]+)/?$ product.php?urlName=$1 [L]
現在用yii
如果網址打product一定會是連到Product這個Controller的actionIndex
就是product/index
如果要加參數就是
product/index/id/12345678
這樣就跟我想像的不一樣.........因為照這規則網址勢必會變類似product/index/id/12345678
這時候就要去config裡改urlManager的rules
我這邊rules是新增這段
'product/<id>'=>'product/index',
ProductController的actionIndex
public function actionIndex() {
$id = Yii::app() -> getRequest() -> getQuery('id');
//do something
$this -> render('index');
}
這樣網址打
product/1234567
她就自動變成product/index/id/12345
reference
http://stackoverflow.com/questions/2760869/yii-framework-controller-action-url-parameters
product/xbox360
或是
product/ps3
作法是
RewriteRule ^product/([a-zA-Z0-9_-]+)/?$ product.php?urlName=$1 [L]
現在用yii
如果網址打product一定會是連到Product這個Controller的actionIndex
就是product/index
如果要加參數就是
product/index/id/12345678
這樣就跟我想像的不一樣.........因為照這規則網址勢必會變類似product/index/id/12345678
這時候就要去config裡改urlManager的rules
我這邊rules是新增這段
'product/<id>'=>'product/index',
ProductController的actionIndex
public function actionIndex() {
$id = Yii::app() -> getRequest() -> getQuery('id');
//do something
$this -> render('index');
}
這樣網址打
product/1234567
她就自動變成product/index/id/12345
reference
http://stackoverflow.com/questions/2760869/yii-framework-controller-action-url-parameters
yii ~ get url parameters
$id = Yii::app()->getRequest()->getQuery('id');
reference
http://stackoverflow.com/questions/2760869/yii-framework-controller-action-url-parameters
reference
http://stackoverflow.com/questions/2760869/yii-framework-controller-action-url-parameters
Discuz ~ 整合Facebook登入註冊
一開始是很蠢的自己寫這功能............
等把流程用好了才發現不是簡單塞session或是自己新增使用者欄位就好......
取值抓資料不是問題
最大的問題是我不知道該如何用Discuz的東西做登入的動作跟註冊
因為不這樣做不行......會有問題XD
後來上網找找找才找到這東西
http://codersclub.org/discuzx/forum.php?mod=viewthread&tid=1454
我用的是文章裡的這個檔案
http://www.mediafire.com/?jdvi4mu3luuquol
下載下來貼到discuz目錄
用管理者登入
進後台
點應用, 會有新的plugin可以安裝叫做
Facebook Connect 2.3
安裝完, 按啟用, 進去設置
輸入Facebook的App ID, App Secret
就可以用了
等把流程用好了才發現不是簡單塞session或是自己新增使用者欄位就好......
取值抓資料不是問題
最大的問題是我不知道該如何用Discuz的東西做登入的動作跟註冊
因為不這樣做不行......會有問題XD
後來上網找找找才找到這東西
http://codersclub.org/discuzx/forum.php?mod=viewthread&tid=1454
我用的是文章裡的這個檔案
http://www.mediafire.com/?jdvi4mu3luuquol
下載下來貼到discuz目錄
用管理者登入
進後台
點應用, 會有新的plugin可以安裝叫做
Facebook Connect 2.3
安裝完, 按啟用, 進去設置
輸入Facebook的App ID, App Secret
就可以用了
Discuz ~ execute php script in template
{eval statement}
前面一定要加eval
以下是我的用法~
reference
http://www.osho.tw/osho/usersguide/advanced_styles.htm
前面一定要加eval
以下是我的用法~
{eval include 'include/main.php';}
{eval print getTvwallBanner();}
{eval print getTvwallBanner();}
reference
http://www.osho.tw/osho/usersguide/advanced_styles.htm
Discuz ~ clear template cache
這問題發生在更新template檔的時候沒反應
上網google了才發現要清除快取= =
(這邊他翻譯成緩存......好大陸的用語XD)
所以我的修改過程就是....
修改了檔案, 要測試
就是用FTP上傳檔案, 在進後台清除快取
再在前台網頁F5看結果
一直反反覆覆
上網google了才發現要清除快取= =
(這邊他翻譯成緩存......好大陸的用語XD)
所以我的修改過程就是....
修改了檔案, 要測試
就是用FTP上傳檔案, 在進後台清除快取
再在前台網頁F5看結果
一直反反覆覆
yii ~ model relation get value example
product_internet_recommend
裡面有個productID是外來建為Product的id
models/ProductInternetRecommend.php
in controller
in view
reference
http://stackoverflow.com/questions/9857209/yii-relations-error-trying-to-get-property-of-non-object
http://www.yiiframework.com/doc/guide/1.1/en/database.arr
裡面有個productID是外來建為Product的id
models/ProductInternetRecommend.php
public function relations()
{
// NOTE: you may need to adjust the relation name and the related
// class name for the relations automatically generated below.
return array(
'product' => array(self::BELONGS_TO, 'Product', 'productID'),
);
}
{
// NOTE: you may need to adjust the relation name and the related
// class name for the relations automatically generated below.
return array(
'product' => array(self::BELONGS_TO, 'Product', 'productID'),
);
}
in controller
$productInternet = ProductInternetRecommend::model() ->with('product')-> findByPk(1);
in view
echo 'asd'.$productInternet->product->price;
reference
http://stackoverflow.com/questions/9857209/yii-relations-error-trying-to-get-property-of-non-object
http://www.yiiframework.com/doc/guide/1.1/en/database.arr
yii ~ call model function
in controller
in models/Product.php
$newProducts = Product::model() -> getNewProduct();
in models/Product.php
public function getNewProduct(){
die('newwwwwwwwwww');
}
die('newwwwwwwwwww');
}
訂閱:
文章 (Atom)

