• Welcome to Simple Machines Community Forum. Please login or sign up.

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 ...
Please do not PM me for support.

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

420Connect.co.uk

I really appreciate your updates and look forward to testing it out when it's ready! :)
www.420Connect.co.uk ~ A Social Network For The #CannabisCommunity ~ Come say "High" ;)

dakey

Great mod.. works great, but I use it together with the Ajax recent topics mod.. and on the recent topics page no tags are displayed, only [this]. Can I add some simple code into the recent topic mod to display the tags?

WadaNon

Quote from: dakey on March 25, 2015, 06:56:49 PM
Great mod.. works great, but I use it together with the Ajax recent topics mod.. and on the recent topics page no tags are displayed, only [this]. Can I add some simple code into the recent topic mod to display the tags?

Try this:

On Sources/Recent.php:
Code (Search) Select

while ($row = $smcFunc['db_fetch_assoc']($request))
{

Code (Add After) Select

$threadTags = makeThreadTags($row['subject']);

$row['subject'] = $threadTags[0];
$threadTags = $threadTags[1];


Code (Search) Select

'link' => '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0">' . $row['subject'] . '</a>',

Code (Replace) Select

'link' => '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0">' . $row['subject'] . '</a>' . $threadTags,


If it doesn't work, tell me. I just did the edit based on reading the mod for 5 minutes.
No to support PMs and spam, yes to everything else :D

dakey

That was the best 5 minutes ever, it works! Many thanks  8)

iain sherriff

This is probably the most appreciated (by my users) mod I have  :)
Also looking forward to integration that 420 requested  ;)
SMF 2.0.12

Kimmie

Do you have a demo site? The small image you posted doesn't really show much. Thanks.

WadaNon

Quote from: Kimmie on April 11, 2015, 01:07:13 PM
Do you have a demo site? The small image you posted doesn't really show much. Thanks.
My site (on my profile here) uses a custom version of the mod for all boards there. Feel free to look and that stuff. I'll probably setup a demo site sometime later.
No to support PMs and spam, yes to everything else :D

WadaNon

Just an update. I was going to upload the update last tuesday but my PC got fried and I can't really upload the update from a phone. Expect the update this monday.

I can give a sneak of what will contain at the very least:
- Per-board permissions.
- Specify in what places the tags would be shown.
- More styles for the tags.
- And some more...

The update that 420connect.info requested will be released separately (but not on the same date as the update) but linked to on the mod page to this thread.
No to support PMs and spam, yes to everything else :D

420Connect.co.uk

Quote from: WadaNon on April 24, 2015, 10:50:42 PM
Just an update. I was going to upload the update last tuesday but my PC got fried and I can't really upload the update from a phone. Expect the update this monday.

I can give a sneak of what will contain at the very least:
- Per-board permissions.
- Specify in what places the tags would be shown.
- More styles for the tags.
- And some more...

The update that 420connect.info requested will be released separately (but not on the same date as the update) but linked to on the mod page to this thread.

Looking forward to this!

Many thanks for considering my request too :)
www.420Connect.co.uk ~ A Social Network For The #CannabisCommunity ~ Come say "High" ;)

gorbi

Why do  you not use an established symbol # to denote tags?

Rain Forest

Quote from: gorbi on April 26, 2015, 05:33:31 AM
Why do  you not use an established symbol # to denote tags?

Quote from: Dragon Fruit on February 17, 2015, 05:03:00 AM
I have 2 suggestions:
Change [ text ] to #text to make tags in topic (Otherwise it's so colorful, see attachment :P);

Yup :)

gorbi

Quote from: WadaNon on February 17, 2015, 12:02:14 PM
Tags can be more than one word so the brackets are perfect for that case.
As twitter

#LarryALoveToRemember
#БУНТАРСКИЙВЫХОДНОЙ
#NepalEarthquake

Rain Forest

Let's wait for WadaNon, maybe he will support it within one of the next versions :)

gorbi

Quote from: Dragon Fruit on April 26, 2015, 01:26:19 PM
Let's wait for WadaNon, maybe he will support it within one of the next versions :)
+100500  ;)

gorbi

You will be able to share posts on social networks at once with #tags

420Connect.co.uk

Just wondered if this was still being supported/developed by Wada..
www.420Connect.co.uk ~ A Social Network For The #CannabisCommunity ~ Come say "High" ;)

iain sherriff

I'm trying to get tags showing in Simple Portal blocks.

I have added the mod css to both portal css files
and
added code as in post #22 here to portal_blocks in sources


forum still works OK but no change to tags in the block............... any one an ideas ? 
SMF 2.0.12

420Connect.co.uk

Quote from: iain sherriff on August 09, 2015, 03:54:49 PM
I'm trying to get tags showing in Simple Portal blocks.

I have added the mod css to both portal css files
and
added code as in post #22 here to portal_blocks in sources


forum still works OK but no change to tags in the block............... any one an ideas ?

I'd also be interested in this should anyone solve it! ;)
www.420Connect.co.uk ~ A Social Network For The #CannabisCommunity ~ Come say "High" ;)

WadaNon

Oh wow. Sorry for that. I just remembered that about the mod. I said that I would get a new version few months ago but work, uni and life stuff came so fast that I completely forgot about it until now that I checked my mail (I have a separate mail for this forum, so...).

I got a new PC and well... I trashed the old drive with the code of the new version. I'm so sorry.

btw do you guys still want the hashtag thing?
No to support PMs and spam, yes to everything else :D

WadaNon

Sorry for the double post but I can't edit my last post :P

Updated the mod to 1.2.

This is only a "cover all bases" update, mainly for users that use SSI.php and want tags too. (*cough*SimplePortal*cough*)
For SimplePortal users: If you modified your blocks to add tag support, please undo them. It should work now out of the box. If not, feel free to reply or send me 20 mails about the matter.
No to support PMs and spam, yes to everything else :D

420Connect.co.uk

Quote from: WadaNon on August 21, 2015, 01:40:59 AM
Oh wow. Sorry for that. I just remembered that about the mod. I said that I would get a new version few months ago but work, uni and life stuff came so fast that I completely forgot about it until now that I checked my mail (I have a separate mail for this forum, so...).

I got a new PC and well... I trashed the old drive with the code of the new version. I'm so sorry.

btw do you guys still want the hashtag thing?

No worries, I completely understand!
and I'd at least appreciate the #thing if you have the time?

.. & sorry, did 1.2 include the mod integration thing?  ???
www.420Connect.co.uk ~ A Social Network For The #CannabisCommunity ~ Come say "High" ;)

WadaNon

Quote from: 420Connect.co.uk on August 22, 2015, 04:39:00 PM
-quote-
No worries, I completely understand!
and I'd at least appreciate the #thing if you have the time?

.. & sorry, did 1.2 include the mod integration thing?  ???

I knew something was missing :/ The update only does the SSI.php edits.

I'll look at that mod thing and the hashtag. I don't promise an eta though. We know how it would end ;)
No to support PMs and spam, yes to everything else :D

420Connect.co.uk

 ;) No worries and thanks again!
www.420Connect.co.uk ~ A Social Network For The #CannabisCommunity ~ Come say "High" ;)

GenesisMUGEN

Sorry to bug ya, love the mod, but on my forum it has one error that I can't seem to fix: the tags show while inside the topic, and when doing a search, but not in topic view.

During install it had trouble with the change to MessageIndex.template.php, which i semi-ignored because I'm an idiot :P

I looked at what it was having trouble with (sadly I forgot now), and whenever i tried to add the code, i'd get a blank page which from what I understand means there's an error? So I removed it and here I am....

WadaNon

Quote from: GenesisMUGEN on August 24, 2015, 09:11:57 PM
Sorry to bug ya, love the mod, but on my forum it has one error that I can't seem to fix: the tags show while inside the topic, and when doing a search, but not in topic view.

During install it had trouble with the change to MessageIndex.template.php, which i semi-ignored because I'm an idiot :P

I looked at what it was having trouble with (sadly I forgot now), and whenever i tried to add the code, i'd get a blank page which from what I understand means there's an error? So I removed it and here I am....

Can you upload your MessageIndex template or the relevant parts of it? It's probably a conflict with an edit that the theme you use or another mod did.
No to support PMs and spam, yes to everything else :D

GenesisMUGEN

Sure thing. I had assumed it was the theme.


WadaNon

Here you go.
* takes note on making that search a bit less specific *
No to support PMs and spam, yes to everything else :D

GenesisMUGEN

Awesome! Thank you so much.

You have no idea how perfect this mod is for my site :P

DJ Omnimaga

This mode is very nice and I like the future Simpleportal/SSI integration idea. It would be nice if tags also showed up anywhere including SimplePortal Recent Topics blocks. :)

WadaNon

Quote from: DJ Omnimaga on September 02, 2015, 12:54:13 AM
This mode is very nice and I like the future Simpleportal/SSI integration idea. It would be nice if tags also showed up anywhere including SimplePortal Recent Topics blocks. :)
What idea? The update is live :P
The tags should show in SimplePortal's blocks since I edited SSI to include them unless I missed something and they don't actually show because I didn't tested (too lazy to dl SimplePortal) >_>
No to support PMs and spam, yes to everything else :D

DJ Omnimaga

Weird, because for me the tags do not show up at all in SimplePortal blocks. The [tag] content is stripped off with this update, but it won't show the tags.

d3vcho

Succesfully tested on my forum and it's very nice.

Congratulations.
"Greeting Death as an old friend, they departed this life as equals"

WadaNon

Quote from: DJ Omnimaga on September 05, 2015, 12:27:03 AM
Weird, because for me the tags do not show up at all in SimplePortal blocks. The [tag] content is stripped off with this update, but it won't show the tags.

Can you try this in SSI.php (do this with all instances of this search)?
Code (Search) Select
$row['subject'] = $threadTags[0];
Code (Replace) Select
$row['subject'] = $threadTags[0] . $threadTags[1];
No to support PMs and spam, yes to everything else :D

DJ Omnimaga

YAY! That fix worked. The tags even show up in a custom recent posts PHP block I am using. Thanks for the update. :)

Do you think the fix will be included in the next update?

GenesisMUGEN

Hey it's me again!
Just wondering, would it be possible in a later update for capitalization? I notice everything is lowercase even if my tags were typed in uppercase. OCD organization :P

WadaNon

Quote from: GenesisMUGEN on September 19, 2015, 09:07:01 AM
Hey it's me again!
Just wondering, would it be possible in a later update for capitalization? I notice everything is lowercase even if my tags were typed in uppercase. OCD organization :P

You can do this in Subs.php
Code (Search) Select
$tag = htmlspecialchars(strtolower($tag));
Code (Replace) Select
$tag = htmlspecialchars($tag);

Quote from: DJ Omnimaga on September 06, 2015, 12:50:49 PM
YAY! That fix worked. The tags even show up in a custom recent posts PHP block I am using. Thanks for the update. :)

Do you think the fix will be included in the next update?

Probably. I did the original update thinking that SimplePortal used the links that SSI already made and not generating the links on its own. I'll have to rethink how to approach it without making a mess.
No to support PMs and spam, yes to everything else :D

GenesisMUGEN


crazyASD

To add cyrillic and other non-latin characters to tags, just change:

Subs.php

$tag = htmlspecialchars(strtolower($tag));
To:
$tag = mb_strtolower($tag, 'UTF-8');

acsieben

Hi,
Tags with spaces don't get processed as they should. I'm trying to get people to use underscores between terms, but it's kind of tricky to do.
Thanks for this mod!

Advertisement: