:::

10. 選單及前台功能

一、 做個漂亮選單http://www.cssmenumaker.com

  1. 請到該站,選擇「Horizontal CSS Menus」選一個喜歡的選單。
  2. 點選「Customize」,並開始輸入想要的連結。設好後按「Preview Menu」即可。
  3. 接著輸入Email,他便會把選單用zip寄到指定信箱。收到後,解開zip檔,然後將menu資料夾複製到模組中,接著開啟installation_instruction.html,依照上面指示,將相關語法加到模組中(echo 出主內容之前即可),記得修改一下路徑,如:
    echo '<link rel="stylesheet" href="menu/menu_style.css" type="text/css" />
    <ul id="menu">
    <li><a href="index.php" title="所有文章" class="current">所有文章</a></li>
    <li><a href="index.php?op=add_form"  title="新文章">新文章</a></li>
    </ul>';

二、 用$_SERVER["REQUEST_URI"]來抓取現在的執行程式

  1. 為了讓class="current"有作用,所以我們利用$_SERVER["REQUEST_URI"]來抓取現在的執行程式,並比對其位置。
    $current1=$_SERVER["REQUEST_URI"]=='/modules/tad_note/index.php'?"class='current'":"";
    $current2=$_SERVER["REQUEST_URI"]=='/modules/tad_note/index.php?op=add_form'?"class='current'":"";
  2. 並把$current1和$current2分別放到對應的連結中即可。

三、 刪除功能

  1. 先修改秀出列表的函數,並加入刪除及修改的連結(op),並設定相對的流程控制。
  2. 讓只給作者看見工具列,先抓uid:$uid=$xoopsUser?$xoopsUser->uid():0;
  3. 迴圈裡加入:$tool=($doc['uid']==$uid)?"<a href='index.php?op=del&note_sn={$doc['note_sn']}'>刪除</a>|<a href='index.php?op=modify&note_sn={$doc['note_sn']}'>修改</a>":"";
  4. $sql="delete from ".$xoopsDB->prefix("tad_notes")." where note_sn='$note_sn'";

四、 修改功能

  1. 傳編號進表單函數(有編號就是修改):add_form($note_sn=null)
  2. 若有編號,則先抓取舊資料:$sql="select * from ".$xoopsDB->prefix("tad_notes")." where note_sn='$note_sn'";
  3. 把抓到的資料塞入欄位的預設值:
    • (1)  選單:$selected=($doc['cate_sn']==$cate['cate_sn'])?"selected":"";
    • (2)  大量文字框:<textarea 略>{$doc['note_content']}</textarea>
    • (3)  原本就有預設值的:$note_date=empty($note_sn)?date("Y-m-d H:i:s"):$doc['note_date'];
    • (4)  單選:$note_public1=($doc['note_public']==1)?"checked":""
    •        $note_public0=($doc['note_public']==0)?"checked":"";
  4. 最後記得加上隱藏欄位,並將編號帶入。

:::

搜尋

QR Code 區塊

https%3A%2F%2Ftad0616.net%2Fmodules%2Ftad_book3%2Fpage.php%3Ftbsn%3D22%26tbdsn%3D617

書籍目錄

展開 | 闔起

線上使用者

46人線上 (12人在瀏覽線上書籍)

會員: 0

訪客: 46

更多…