:::

11-2 列出單一活動

一、製作函數

  1. 讀出單一活動的流程已經有了,所以,直接完成函數show_action($action_id)
    //列出指定活動
    function show_action($action_id)
    {
        global $db, $smarty;
    
        $sql    = "SELECT * FROM `actions` where `action_id` ='{$action_id}'";
        $result = $db->query($sql);
        if (!$result) {
            throw new Exception($db->error);
        }
        $action = $result->fetch_assoc();
        $smarty->assign('action', $action);
    }

二、修改主樣板

  1. 編輯 templates\index.tpl
    {if $op=="regist"}
      {include file='regist_form.tpl'} 
    {elseif $op=="list_action"}
      {include file='list_action.tpl'}
    {elseif $op=='show_action'}
      {include file='show_action.tpl'}
    {else}
      {$content}
    {/if}

三、新增專屬樣板

  1. 新增 templates\show_action.tpl
    <h2>{$action.title}</h2>
    
    <div class="panel panel-default">
      <div class="panel-heading">活動日期:{$action.action_date}</div>
      <div class="panel-body">
        {$action.content}
      </div>
      <div class="panel-footer">報名截止日:{$action.end_date}</div>
    </div>
    

     


:::

書籍目錄

展開 | 闔起

快速登入


https%3A%2F%2Fcampus-xoops.tn.edu.tw%2Fmodules%2Ftad_book3%2Fpage.php%3Ftbdsn%3D736%26tbsn%3D27

計數器

今天: 4974497449744974
昨天: 2489248924892489
總計: 8026956802695680269568026956802695680269568026956