Stylize the topic Tags for SMF

Started by Mick, Sep 13, 2018

Sep 13, 2018 Last Edit: Nov 03, 2019 by Mick

We're going to add some styling to the topic tag mod to make it look purdy from the boring and plain link state. I've been using this mod for a long time but never liked the original html without any styles. With a bit of CSS we're going to make it even cooler.


Go from this

To this


Demo: Right here at the end of this post.

Download the Tagging System for topics at  SMF mod site and once installed,

Open:
./Themes/default/Display.template.php

Find:



// Tagging System
echo '
<div class="clearfix windowbg largepadding">


<b>', $txt['smftags_topic'], '</b>';



foreach ($context['topic_tags'] as $i => $tag)
{
echo '<a href="' . $scripturl . '?action=tags;tagid=' . $tag['ID_TAG']  . '">' . $tag['tag'] . '</a>&nbsp;';
if(!$context['user']['is_guest'] && allowedTo('smftags_del'))
echo '<a href="' . $scripturl . '?action=tags;sa=deletetag;tagid=' . $tag['ID']  . '"><font color="#FF0000">[X]</font></a>&nbsp;';

}

global $topic;
if(!$context['user']['is_guest'] && allowedTo('smftags_add'))
echo '
&nbsp;<a href="' . $scripturl . '?action=tags;sa=addtag;topic=',$topic, '">' . $txt['smftags_addtag'] . '</a>';

echo '
</div>';




// End Tagging System





Replace with:
// Tagging System
echo '
<div class="clearfix windowbg largepadding">


', $txt['smftags_topic'], '';



foreach ($context['topic_tags'] as $i => $tag)
{
echo '<span class="smf_tags"><a href="' . $scripturl . '?action=tags;tagid=' . $tag['ID_TAG']  . '">' . $tag['tag'] . '</a></span>&nbsp;';
if(!$context['user']['is_guest'] && allowedTo('smftags_del'))
echo '<a href="' . $scripturl . '?action=tags;sa=deletetag;tagid=' . $tag['ID']  . '"><font color="#FF0000">[X]</font></a>&nbsp;';

}

global $topic;
if(!$context['user']['is_guest'] && allowedTo('smftags_add'))
echo '
&nbsp;<a href="' . $scripturl . '?action=tags;sa=addtag;topic=',$topic, '">' . $txt['smftags_addtag'] . '</a>';

echo '
</div><br />';




// End Tagging System


Open your theme's CSS file and at the very end, add,
.smf_tags a {
       background-color: #f9f9f9;
       color: #333333;
       padding: 10px 20px;
       font-size: 14px;
       margin: 2px;
       text-align: center;
       display: inline-block;
       text-transform: uppercase;
}
.smf_tags a:hover {
       background-color: #0984e3;
       color: #ffffff;
}


Replace colors with your own to suit your theme.

Reference and Credits:
Tagging System for topics
SMFHacks.com Team