Toggle main menu visibility
新聞
下載
教材
影音
討論
其他選單
好站連結
行事曆
電子相簿
常見問題
萬用表單
即時留言簿
友站消息
社大學員
:::
登入
登入
帳號
密碼
登入
重整畫面
:::
所有書籍
「XOOPS 模組開發」目錄
MarkDown
11. XOOPS語系功能
1. 開發環境
2. XOOPS模組基本結構
2-1 tad_honor 資料庫結構
2-2 school_news 資料庫結構
2-3 匯出SQL檔的方法
3. 模組管理後台結構
4. XOOPS的表單物件
5. 新增、列出功能
6. XOOPS文字過濾
7. 分頁功能
8. 前台檔案結構
9. 修改、刪除功能
10. 模組偏好設定
11. XOOPS語系功能
12. XOOPS的樣板檔
13. 內建搜尋功能
14. XOOPS的評論功能
15. 製作XOOPS區塊
16. FireFox內建「網頁開發者」工具
16-1 WebDeveloper附加元件
16-2 FireBug附加元件
16-3 用Selenium IDE來測試
17. XOOPS上傳
18. tad_honor 範例
18-1 xoops_version.php
18-2 language/tchinese_utf8/modinfo.php
18-3 sql/mysql.sql
18-4 admin/menu.php
18-5 admin/main.php
18-6 templates/tad_honor_adm_main.html
18-7 index.php
18-8 function.php
18-9 templates/tad_honor_index.html
19. school_news 校園佈告欄範例程式碼
19-1 xoops_version.php
19-2 sql/mysql.sql
19-3 admin/menu.php
19-4 admin/main.php
19-5 templates/school_news_adm_main.html
13. 內建搜尋功能
XOOPS 模組開發 ========== ### 一、 模組套用簡易樣板步驟 ``` $modversion['templates'][1]['file'] = 'tad_honor_index_tpl.html'; $modversion['templates'][1]['description'] = 'index.php的樣板'; ``` ``` $xoopsOption['template_main'] = "tad_honor_index_tpl.html"; ``` 1. 請到xoops\_version.php做以下設定。設定也是兩個一組,陣列從1開始。 2. -
$modversion\['templates'\]\[1\]\['file'\] = 'tad\_honor\_index\_tpl.html';
檔名盡量特別,別和其他樣板檔相衝。 -
$modversion\['templates'\]\[1\]\['description'\] = "佈景說明";
樣板描述,從後台的樣板管理就會看得到。(常數不用加引號,不然系統讀不到) 3. 建立templates/tad\_honor\_index\_tpl.html,該檔內容一行即可,樣板碼可自訂:<{$樣板碼}> 例如:<{$content}> 4. 到後台更新您的模組,讓XOOPS重讀xoops\_version.php設定檔。 5. 在index.php前面加入 6. 用「
$xoopsTpl->assign( "content" , $main) ;
」來把內容套入樣板,其中 content就是樣板標籤<{$content}>,而$main就是要套用進去的內容。 7. $xoopsTpl是在header.php產生的物件,所以,
$xoopsTpl必須在header.php之後使用
。若要在函數中使用,記得
global $xoopsTpl;
### 二、 設一個獨立頁面view.php ``` $xoopsOption['template_main'] = "tad_honor_view_tpl.html"; ``` ``` $modversion['templates'][2]['file'] = 'tad_honor_view_tpl.html'; $modversion['templates'][2]['description'] = 'view.php的樣板'; ``` 1. 將總列表和單一頁面都設在index.php,這樣雖然可以,但要套用比較精細的樣板時,難度會增加許多,因此建議增設一個獨立頁面,也就是秀出單一文章用的頁面,如此在製作樣板時會更簡單。 2. 另存index.php為view.php,並留下顯示頁面的函數,其餘函數及流程均可刪除。另外,此頁套用新的樣板檔: 3. 將樣板檔 tad\_honor\_index\_tpl.html 複製為 tad\_honor\_view\_tpl.html 4. 到xoops\_version.php多一組樣板設定: 5. 到後台更新模組。 6. 修改index.php中的連結至view.php,搜尋檔的$ret\[$i\]\['link'\]也一樣需要修改。 ### 三、 精細的樣板 1. 把樣板細分成各種網頁元件,由樣板提供標籤,PHP負責產生標籤所需的套用值。 2. 按照樣版產生流程,替view.php產生一組樣板tad\_honor\_view.html,其內容為: tad\_honor\_view.html ```
恭賀「<{$students}>」
恭喜
<{$students}>
於
<{$date}>
榮獲
<{$descript}>
<{if $teachers}>
指導老師:<{$teachers}>
<{/if}>
<{if $note}>
<{$note}>
<{/if}> ``` view.php ``` $xoopsTpl->assign( "date" , $all['honor_date']) ; $xoopsTpl->assign( "students" , $all['honor_students']) ; $xoopsTpl->assign( "descript" , $all['honor_descript']) ; $xoopsTpl->assign( "teachers" , $all['honor_teachers']) ; $xoopsTpl->assign( "note" , $all['honor_note']) ; ``` ### 四、 Smarty迴圈 1. 列表部份需要用到smarty迴圈。 tad\_honor\_index.html ```
<{foreach item=honor from=$honor}>
<{$honor.honor_students}>
<{$honor.honor_date}>
<{$honor.honor_descript}>
<{$honor.honor_teachers}>
<{/foreach}>
<{$bar}>
``` index.php ``` $i=0; while($all=$xoopsDB->fetchArray($result)){ //處理部份省略 $main[$i]['honor_sn']=$all['honor_sn']; $main[$i]['honor_students']=$all['honor_students']; $main[$i]['honor_date']=$all['honor_date']; $main[$i]['honor_descript']=$all['honor_descript']; $main[$i]['honor_teachers']=$all['honor_teachers']; $i++; } $xoopsTpl->assign( "honor" , $main) ; $xoopsTpl->assign( "bar" , $bar) ; ``` 五、在樣板中使用模組語系常數 若語系中有如下定義: ``` define("_MI_HONOR_YEAR" , "學年度"); ``` 那麼在樣板中就可以用這種方式呼叫該常數: ``` <{$smarty.const._MI_HONOR_YEAR}> ```
:::
搜尋
search
進階搜尋
QR Code 區塊
快速登入
所有討論區
「PHP全端開發」線上課程討論區
XOOPS使用討論區
一般研習學員
社大學員專用
路過哈啦區
XOOPS佈景設計
XOOPS模組開發
Tad書籍區
即時留言簿
書籍目錄
展開
|
闔起
線上使用者
149
人線上 (
83
人在瀏覽
線上書籍
)
會員: 0
訪客: 149
更多…