Modern Tags

by MixRo 0 Stars 0 Downloads

Give the ability to add tags inside threads.

Project Details

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:
<!-- Find: -->
{$posticons}

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

Inside showthread template
<!-- 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

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 :

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

Add below to it this :

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

Previews

 
Author
MixRo
Collaborators
None
Version
1.4
Submitted
7 hours ago
Last Updated
7 hours ago
Bug Tracking
Disabled
MyBB Versions
1.8.x