1.8.x Tính Năng: Modern Tags

Preview

Tác giả: MixRo

Phiên bản: 1.6

Gửi lúc: 17/05/2025

Cập nhật lúc: 10/08/2025

Show Thread Index Page Forum Display Admin Control Panel
Mô tả
Description : Give the ability to add tags inside threads.

Features:
 Thread Creation
  • Adds a modern, styled Tagify input field on newthread.php
  •  Input matches MyBB  .textbox theme (dark mode + consistent padding)
  • Allows inserting multiple tags per thread
  •  Autocomplete suggestions from previously used tags

Thread Editing
  • Allows editing tags from editpost.php (first post only)
  •  Loads existing tags into the input field
  •  Saves updated tags and replaces old ones
  •  Automatically updates sidebar tag cache
 
Database + Storage
  • Tags are stored in a custom mybb_threadtagstable
  • Automatically created on plugin activation
  • One entry per tag per thread (tid + tag)
 
Display
  • Tags are displayed in showthread.php below the thread title
  • Tags are clickable, linking to search results
  • Uses a custom CSS class .item-blog-tag for visual style (background image, font, shadow)
  • Also styled consistently in the sidebar
 
Sidebar Integration
  • Optional setting: enable/disable sidebar tags from ACP
  •  Variable {$sidebartags} can be placed in any template
  •  Displays the last 20 most recently used tags
  •  Styled identically to showthread tags
  • Data is cached using MyBB's $cache system to reduce DB load

Configuration:

Modify newthread template:
Code: 
<!-- Find: -->
{$posticons}

<!-- Add before it: -->
{$tags_input}

Inside showthread template
Code: 
<!-- Find: -->
{$thread['threadprefix']}

<!-- Add after it: -->
{$showthread_tags}

If you have to keep {$sidebartags} that will display the last 20 tags used in any template where the variable {$sidebartags} exists make sure that in

Code: 
ACP -> Configuration -> Settings -> Plugin Settings ->  Modern Tags Settings 
The Option Enable Sidebar Recent Tags is set to Yes


If you want the tag links (like search.php?action=tag&tag=cs) to actually list matching threads :

Go to search.php in your root and find the line :

Code: 
$mybb->input['action'] = $mybb->get_input('action');

Add below to it this :

Code: 
if ($mybb->input['action'] === 'tag' && !empty($mybb->input['tag'])) {
    global $theme, $templates, $header, $footer, $headerinclude, $lang;

    add_breadcrumb("Tag Search", "search.php?action=tag");
    $tag = htmlspecialchars_uni($mybb->get_input('tag'));
    $escaped_tag = $db->escape_string($tag);

    // Find threads with this tag
    $tids = [];
    $query = $db->simple_select('threadtags', 'tid', "tag='" . $escaped_tag . "'");
    while ($row = $db->fetch_array($query)) {
        $tids[] = (int)$row['tid'];
    }

    if (empty($tids)) {
        error("No threads found for tag: <strong>{$tag}</strong>");
    }

    $threadlist = "";
    $thread_query = $db->query("
        SELECT t.*, f.name AS forumname
        FROM " . TABLE_PREFIX . "threads t
        LEFT JOIN " . TABLE_PREFIX . "forums f ON (f.fid = t.fid)
        WHERE t.tid IN (" . implode(",", $tids) . ") AND t.visible=1
        ORDER BY t.lastpost DESC
    ");

    while ($thread = $db->fetch_array($thread_query)) {
        $thread['subject'] = htmlspecialchars_uni($thread['subject']);
        $thread['threadlink'] = get_thread_link($thread['tid']);
        $thread['forumlink'] = get_forum_link($thread['fid']);
        $threadlist .= "<li style='margin-bottom: 10px;'>
            <a href='{$thread['threadlink']}' style='font-weight: bold;'>{$thread['subject']}</a>
            <div style='font-size: 11px; color: #999;'>Forum: <a href='{$thread['forumlink']}'>{$thread['forumname']}</a></div>
        </li>";
    }

    eval("\$searchresults = \"<html xml:lang="en" lang="en" xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title>Threads tagged with {$tag}</title>
        {\$headerinclude}
    </head>
    <body>
        {\$header}
        <table width='100%' border='0' align='center' cellpadding='10'>
            <tr>
                <td class='trow1'>
                    <h2 style='margin-bottom: 15px;'>Threads tagged with: <span style='color: #3b8beb;'>#{$tag}</span></h2>
                    <ul style='list-style: none; padding-left: 0;'>{$threadlist}</ul>
                </td>
            </tr>
        </table>
        {\$footer}
    </body>
    </html>\";");

    output_page($searchresults);
    exit;
}

Inside the Archive you will find :
The php plugin
The css required to be added in global.css
The image used for tags appearance


UPDATE 13/06/2025

- Fixed the Bug where you can edit a thread that has tags , the tags disappear
- Added an option in plugin settings to have the tags displayed inside the threadlist

to have the tags displayed inside the threadlist go to forumdisplay_thread template and add the variable {$thread['taglist']}
Sự miêu tả: Cung cấp khả năng thêm thẻ bên trong các chủ đề.

Tính năng:
Tạo chủ đề
  • Thêm một hiện đại, phong cách Tagify trường đầu vào trên newthread.php
  •  Đầu vào phù hợp với chủ đề MyBB .textbox (chế độ tối + đệm nhất quán)
  • Cho phép chèn nhiều thẻ trên mỗi luồng
  •  Đề xuất tự động hoàn thành từ các thẻ đã sử dụng trước đây

Chỉnh sửa chủ đề
  • Cho phép chỉnh sửa thẻ từ editpost.php (chỉ bài đầu tiên)
  •  Tải các thẻ hiện có vào trường nhập liệu
  •  Lưu thẻ cập nhật và thay thế thẻ cũ
  •  Tự động cập nhật bộ nhớ cache thẻ thanh bên

Cơ sở dữ liệu + Lưu trữ
  • Thẻ được lưu trữ trong một mybb_threadtagstable tùy chỉnh
  • Tự động tạo khi kích hoạt plugin
  • Một mục nhập cho mỗi thẻ trên mỗi luồng (tid + thẻ)

Trưng bày
  • Thẻ được hiển thị ở showthread.php bên dưới tiêu đề chủ đề
  • Thẻ là Có thể nhấp, liên kết đến kết quả tìm kiếm
  • Sử dụng lớp CSS tùy chỉnh .item-blog-tag cho kiểu hình ảnh (hình nền, phông chữ, bóng)
  • Cũng được tạo kiểu nhất quán trong Bên

Tích hợp thanh bên
  • Cài đặt tùy chọn: bật/tắt thẻ thanh bên từ ACP
  •  Biến {$sidebartags} có thể được đặt trong bất kỳ mẫu nào
  •  Hiển thị cuối cùng 20 thẻ được sử dụng gần đây nhất
  •  Được tạo kiểu giống hệt với thẻ showthread
  • Dữ liệu được lưu vào bộ nhớ đệm bằng hệ thống $cache của MyBB để giảm tải DB

Cấu hình:

Sửa đổi mẫu luồng mới:
<!-- tìm: -->
{$posticons}

<!-- Thêm trước nó: -->
{$tags_đầu vào}

Mẫu chủ đề hiển thị bên trong
<!-- tìm: -->
{$thread['threadprefix']}

<!-- Thêm sau nó: -->
{$showthread_thẻ}

Nếu bạn phải giữ {$sidebartags} sẽ hiển thị 20 thẻ cuối cùng được sử dụng trong bất kỳ mẫu nào có biến {$sidebartags} tồn tại, hãy đảm bảo rằng trong

ACP -> Cấu hình -> Cài đặt -> Cài đặt plugin -> Hiện đại Tags Cài đặt 
Tùy chọn Bật thẻ gần đây của thanh bên được đặt thành


Nếu bạn muốn các liên kết thẻ (như search.php?action=tag&tag=cs) thực sự liệt kê các chủ đề phù hợp:

Đi tới search.php trong gốc của bạn và tìm dòng:

$mybb->input['hành động'] = $mybb->get_input('hành động');

Thêm vào bên dưới điều này:

if ($mybb->input['action'] === 'tag' & !empty($mybb->input['tag'])) {
    $theme toàn cầu, $templates, $header, $footer, $headerinclude, $lang;

add_breadcrumb("Tìm kiếm thẻ", "search.php?action=tag");
    $tag = htmlspecialchars_uni($mybb->get_input('thẻ'));
    $escaped_tag = $db->escape_string($tag);

Tìm chủ đề có thẻ này
    $tids = [];
    $query = $db->simple_select('threadtags', 'tid', "tag='" . $escaped_tag . "'");
    trong khi ($row = $db->fetch_array($query)) {
        $tids[] = (int)$row['tid'];
    }

if (trống ($tids)) {
        error("Không tìm thấy luồng nào cho thẻ: <strong>{$tag}</strong>");
    }

$threadlist = "";
    $thread_query = $db->query("
        CHỌN t.*, f.name AS tên diễn đàn
        TỪ " . TABLE_PREFIX . "chủ đề t
        TRÁI THAM GIA " . TABLE_PREFIX . "diễn đàn f BẬT (f.fid = t.fid)
        NƠI t.tid IN (" . implode(",", $tids) . ") VÀ t.visible=1
        ĐẶT HÀNG BỞI T.LASTPOST DESC
    ");

while ($thread = $db->fetch_array($thread_query)) {
        $thread['chủ ngữ'] = htmlspecialchars_uni($thread['chủ ngữ']);
        $thread['liên kết luồng'] = get_thread_link($thread['tid']);
        $thread['forumlink'] = get_forum_link($thread['fid']);
        $threadlist .= "<li style='margin-bottom: 10px;'>
            <a href='{$thread['threadlink']}' style='font-weight: bold;' >{$thread['chủ đề']}</a>
            <div style='font-size: 11px; color: #999;'>Forum: <a href='{$thread['forumlink']}'>{$thread['forumname']}</a></div>
        ";</li>
    }

eval("\$searchresults = \"<html xml:lang="en" lang="en" xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title>Các chủ đề được gắn thẻ {$tag}</title>
        {\$headerinclude}
    </head>
    <body>
        {\$header}
        <width bảng = '100%' border= '0' align = 'center' cellpadding = '10'>
            <tr>
                <td class='trow1'>
                    <h2 style='margin-bottom: 15px;'>Threads được gắn thẻ: <span style='color: #3b8beb;'>#{$tag}</span></h2>
                    <ul style='list-style: none; padding-left: 0;'>{$threadlist}</ul>
                </td>
            </tr>
        </table>
        {\$footer}
    </body>
    \"</html>;");

output_page ($searchresults);
    thoát;
}

Bên trong Kho lưu trữ, bạn sẽ tìm thấy:
Plugin php
CSS cần được thêm vào global.css
Hình ảnh được sử dụng để xuất hiện thẻ


CẬP NHẬT 13/06/2025

- Đã sửa lỗi nơi bạn có thể chỉnh sửa một chủ đề có thẻ, các thẻ biến mất
- Thêm một tùy chọn trong cài đặt plugin để hiển thị các thẻ bên trong danh sách chủ đề

Để các thẻ hiển thị bên trong danh sách chủ đề, hãy forumdisplay_thread mẫu và thêm biến {$thread['taglist']}