跳至主內容區

XOOPS輕鬆架

:::

主內容區域

選擇後會自動跳轉頁面

7-5 完成側邊欄的近期新聞

一、完成側邊欄新聞列表

  1. 修改 index.phpswitch()之後, 用 all() 取得指定數量的新聞的文章,做成 $aside_news 的樣板變數送至樣板檔。
    $smarty->assign('aside_news', all(0, 15));
    $smarty->assign('now_op', $op);
    $smarty->display('index.tpl');

     

  2. 最後編輯 templates/aside.tpl 就完成了!
    <div class="card my-4">
        <div class="card-header">近期新聞</div>
        <ul class="list-group list-group-flush">
            {foreach $aside_news as $key => $news}
                <li class="list-group-item">
                    {$news.report_date} 【{$news.school_name}】
                    <div><a href="index.php?id={$news.id}" class="text-decoration-none">{$news.news_title}</a></div>
                </li>
            {/foreach}
        </ul>
    </div>

     

  3. 看起來像這樣:

二、讓發布頁面也有側邊欄內容

  1. 修改 admin.php ,一樣在 switch() 之後用 all() 取得指定數量的新聞的文章,做成 $aside_news 的樣板變數送至樣板檔。
  2. 不過 all() 以及其相關函數目前是放在 index.php ,為了讓 admin.php 也能使用,需將之移至 function.php,包括 all()convertMediaToJson()truncate_string()..等含函數,都需移至 function.php

 

選擇後會自動跳轉頁面

:::

左邊區域內容

書籍目錄

展開 | 闔起

快速登入


右邊區域內容

請掃此 QR Code 可連至此頁面

計數器

今天: 2052205220522052
昨天: 3465346534653465
總計: 9590865959086595908659590865959086595908659590865

頁尾區域