News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Super Simple Thread Tags

Started by WadaNon, February 15, 2015, 05:18:42 PM

Previous topic - Next topic

WadaNon

Link to Mod

Allows users to add tags to their topics by just wrapping them in brackets at the title.

Mod's source repo can be found in Gitlab.

Features

  • Allows an easy visual categorization of threads by seeing tags.
  • Tags are coloured automatically based on the contents of the tag.
  • Clicking a tag will show all threads with that tag as long the user can use your forum's search

Configuration
None required. To disable the tags, the mod must be uninstalled.

Special Information
This mod makes use of CSS3 features, mainly border-radius and rgba colouring.

Special Thanks
I want to thank the ABXD team for their software, where the original tag code came from.
The license for ABXD may be seen here.

Update History
(1.2) 21-Ago-2015 - Add SSI support for tags. I'm so sorry.
(1.1a) 22-Feb-2015 - Fix an error related to guest tag searching.
(1.1) 17-Feb-2015 - Make use of SMF Search as a "tag search" function.
(1.0a) 11-Feb-2015 - Make tags more consistent within all SMF actions.

Update Information
This mod doesn't require to uninstall for upgrading as long you're in the last 3 versions before the latest one. This is to make upgrades easier in my end.

Note: If you have errors upgrading from 1.1a, try uninstalling the mod first, then install 1.2.

License
This mod is released under the MIT license.
No to support PMs and spam, yes to everything else :D

Steve

How cool is that?? Runs off to try it ...
DO NOT pm me for support unless asked to!

WadaNon

I updated the mod to 1.1.
Just install over and the mod will be upgraded.

This update adds a "tag search" system that makes use of SMF search. If a user is logged in on the forum and search is enabled for that user, they can click that tag to search more threads with that tag.
No to support PMs and spam, yes to everything else :D

Rain Forest

Nice tag and update! Will try to convert it to my forums on 2.0.8 today! :)

BTW, how many tags are allowed per topic?

WadaNon

Quote from: Dragon Fruit on February 17, 2015, 03:29:54 AM
Nice tag and update! Will try to convert it to my forums on 2.0.8 today! :)

BTW, how many tags are allowed per topic?

It should work for 2.0.8 with emulation. If not, I can fix it :)

There is no limit for tags as long the thread title has space for them (80 characters iirc)
No to support PMs and spam, yes to everything else :D

Rain Forest

There seem to be an issue in messageindex.template.php

There was a problem loading the /Themes/default/MessageIndex.template.php template or language file. Please check the syntax and try again - remember, single quotes (') often have to be escaped with a slash (\). To see more specific error information from PHP, try accessing the file directly.

syntax error, unexpected T_IF, expecting ',' or ';'


Find
', $topic['is_sticky'] ? '<strong>' : '', '<span id="msg_' . $topic['first_post']['id'] . '">', $topic['first_post']['link'], (!$context['can_approve_posts'] && !$topic['approved'] ? '&nbsp;<em>(' . $txt['awaiting_approval'] . ')</em>' : ''), '</span>', $topic['is_sticky'] ? '</strong>' : ''

Add after
, $topic['first_post']['tags'] ? ' ' . $topic['first_post']['tags'] : ''




In my messageindex, this is my line:
', ($topic['is_sticky'] || $topic['new']) ? '<strong>' : '', '<span id="msg_' . $topic['first_post']['id'] . '">', $topic['first_post']['link'], (!$context['can_approve_posts'] && !$topic['approved'] ? '&nbsp;<em>(' . $txt['awaiting_approval'] . ')</em>' : ''), '</span>', ($topic['is_sticky'] || $topic['new']) ? '</strong>' : '' ;

If I put your code after this line, it says Parse error.
IF I replace my code with your line it also says it has a parse error.. :(

WadaNon

Try this. It should work. If it doesn't, I should sleep before doing support :p
No to support PMs and spam, yes to everything else :D

Rain Forest

Thanks! That worked indeed! :)

I have 2 suggestions:
Change [ text ] to #text to make tags in topic (Otherwise it's so colorful, see attachment :P);

Personally to my forums it for the better to enable/disable per board :)

WadaNon

Quote from: Dragon Fruit on February 17, 2015, 05:03:00 AM
Thanks! That worked indeed! :)

I have 2 suggestions:
Change [ text ] to #text to make tags in topic (Otherwise it's so colorful, see attachment :P);

Personally to my forums it for the better to enable/disable per board :)

Tags can be more than one word so the brackets are perfect for that case.

And for the colorful, that's the intention of the tags :P
You can change it by opening Subs.php and changing this part:


// That multiplier is only there to make "nsfw" and "18" the same color.
$color = 'hsl(' . (($hash * 57) % 360) . ', 70%, 40%)';


Experiment by changing the second and third values (70% and 40%) to your liking.

Due to how I make the tags on the board, the per board setting won't there be for some time.
No to support PMs and spam, yes to everything else :D

Rain Forest

What particular code do I need to change if I would like to change [text] to #text? :)

Is it this one? :)
$title = str_replace('[' . $tag . ']', '', $title);

WadaNon

Quote from: Dragon Fruit on February 17, 2015, 12:14:48 PM
What particular code do I need to change if I would like to change [text] to #text? :)

This one:
preg_match_all('/\[(.*?)\]/', $title, $matches);

Be sure to change this line too:
$tags .= '<a class="threadTag" style="background-color: ' . $color . ';" href="' . $scripturl . '?action=search2;search=' . htmlspecialchars('[' . $tag . ']') . '" title="' . sprintf($txt['sstd_search_tag'], $tag) . '">' . $tag . '</a>';

And Modificacions.english.php too:
$txt['sstd_search_tag'] = 'Search all threads that are tagged [%1$s]';

Have fun.
No to support PMs and spam, yes to everything else :D

Rain Forest


Mortissimov

I found an error with the guest tag searching, produces this error:

8: Undefined index: is_guest
File: /wwwroot/Sources/Subs.php
Line: 4442


Because of:

if (!$context['is_guest'] && $canSearch)

If somebody get this error too, than change it in Sources/Subs.php to:

if (!$context['user']['is_guest'] && $canSearch)

WadaNon

Quote from: navMartin on February 22, 2015, 05:18:12 AM
I found an error with the guest tag searching, produces this error:

8: Undefined index: is_guest
File: /wwwroot/Sources/Subs.php
Line: 4442


Because of:

if (!$context['is_guest'] && $canSearch)

If somebody get this error too, than change it in Sources/Subs.php to:

if (!$context['user']['is_guest'] && $canSearch)

Thanks. I have uploaded 1.1a with (only) the fix.
No to support PMs and spam, yes to everything else :D


iain sherriff

SMF 2.0.12

420Connect.co.uk

www.420Connect.co.uk ~ A Social Network For The #CannabisCommunity ~ Come say "High" ;)

WadaNon

Quote from: 420connect.info on March 18, 2015, 05:58:30 PM
Would there be any chance of this working along side http://custom.simplemachines.org/mods/index.php?mod=579 ?

I'll look on that. It shouldn't be that hard to integrate.
No to support PMs and spam, yes to everything else :D

420Connect.co.uk

www.420Connect.co.uk ~ A Social Network For The #CannabisCommunity ~ Come say "High" ;)

WadaNon

I thought that I posted this last weekend... Oh well.

I'm still working on the stuff that 420connect.info requested. I got the basic stuff working but there are some quirks that I want to get done first (the next update has the per board permissions stuff) and uni/college/whatever you want to call it leaves me with so little time for that. Don't expect the update soon but if it's possible, I'll try to get it done on these weeks.
No to support PMs and spam, yes to everything else :D

Advertisement: