2014年11月3日 星期一

Xoops 常用語法



常用語法

  1. 引入mainfile.php
    1.include dirname(__FILE__) . DIRECTORY_SEPARATOR . 'mainfile.php';
    PHP 如何取得 現在檔案的目錄 與 上層目錄
    DIRECTORY_SEPARATOR 是PHP内部常數,表示路徑分隔符在win裡為 \ ,在linux 裡為 /
  2. 判斷是否為會員
    1.if (!is_object($xoopsUser)) {
    2.redirect_header('index.php', 3, _NOT_NOACCESS);
    3.exit();
    4.}
    5. 
    6.$uid = $xoopsUser->getVar('uid');# ---- 取得uid ----

     
  3. 1.用「uid」取得「uname」
           $uname=XoopsUser::getUnameFromId($uid,0); # 以$uid 取得帳號 
           $name=XoopsUser::getUnameFromId($uid,1);  # 以$uid 取得姓名  
    01.{
    10. 
    11.}

     
  4. 取得模組名稱
    1.$thisModuleDir = $GLOBALS['xoopsModule']->getVar('dirname');

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1. 訂xx、取xx
    01.
    05.if (!$status) {
    06.$notification_handler->unsubscribe($category, $item_id, $event, $module_id, $user_id);
    07.} else {
    08.$notification_handler->subscribe($category, $item_id, $event);
    09.}
    10. 
    11.

1.用「uid」xxxxxxxxxxxxxxxxxxxx
       $uname=Xxxxxxxxxxxxxxxxxx; # 以$SSID 取得

 


工作室作品

沒有留言:

張貼留言