Simple Machines Community Forum

Customizing SMF => Modifications and Packages => Topic started by: WadaNon on February 15, 2015, 05:18:42 PM

Title: Super Simple Thread Tags
Post by: WadaNon on February 15, 2015, 05:18:42 PM
Link to Mod (http://custom.simplemachines.org/mods/index.php?mod=4034)

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 (https://gitlab.com/wadanon/super-simple-thread-tags).

Features
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 (https://github.com/ABXD/ABXD/blob/master/LICENSE.md).

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.
Title: Re: Super Simple Thread Tags
Post by: Steve on February 15, 2015, 08:25:29 PM
How cool is that?? Runs off to try it ...
Title: Re: Super Simple Thread Tags
Post by: WadaNon on February 17, 2015, 02:18:56 AM
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.
Title: Re: Super Simple Thread Tags
Post by: Rain Forest 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?
Title: Re: Super Simple Thread Tags
Post by: WadaNon on February 17, 2015, 04:09:08 AM
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)
Title: Re: Super Simple Thread Tags
Post by: Rain Forest on February 17, 2015, 04:41:03 AM
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.. :(
Title: Re: Super Simple Thread Tags
Post by: WadaNon on February 17, 2015, 04:51:46 AM
Try this. It should work. If it doesn't, I should sleep before doing support :p
Title: Re: Super Simple Thread Tags
Post by: Rain Forest 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 :)
Title: Re: Super Simple Thread Tags
Post by: WadaNon on February 17, 2015, 12:02:14 PM
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.
Title: Re: Super Simple Thread Tags
Post by: Rain Forest 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? :)

Is it this one? :)
$title = str_replace('[' . $tag . ']', '', $title);
Title: Re: Super Simple Thread Tags
Post by: WadaNon on February 17, 2015, 12:23:26 PM
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.
Title: Re: Super Simple Thread Tags
Post by: Rain Forest on February 17, 2015, 01:42:33 PM
Edit: Never mind, I give up. :P
Title: Re: Super Simple Thread Tags
Post by: Mortissimov 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)
Title: Re: Super Simple Thread Tags
Post by: WadaNon on February 22, 2015, 11:52:38 AM
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.
Title: Re: Super Simple Thread Tags
Post by: Mortissimov on February 22, 2015, 12:56:14 PM
You're welcome. ;)
Title: Re: Super Simple Thread Tags
Post by: iain sherriff on March 02, 2015, 08:43:45 PM
Love this Mod....thank you  :)
Title: Re: Super Simple Thread Tags
Post by: 420Connect.co.uk 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 ?

Title: Re: Super Simple Thread Tags
Post by: WadaNon on March 18, 2015, 11:07:41 PM
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.
Title: Re: Super Simple Thread Tags
Post by: 420Connect.co.uk on March 19, 2015, 12:07:25 PM
so much love for you!  :-*
Title: Re: Super Simple Thread Tags
Post by: WadaNon on March 24, 2015, 12:20:50 AM
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.
Title: Re: Super Simple Thread Tags
Post by: 420Connect.co.uk on March 24, 2015, 04:37:32 AM
I really appreciate your updates and look forward to testing it out when it's ready! :)
Title: Re: Super Simple Thread Tags
Post by: 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?
Title: Re: Super Simple Thread Tags
Post by: WadaNon on March 25, 2015, 08:19:21 PM
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.
Title: Re: Super Simple Thread Tags
Post by: dakey on March 26, 2015, 04:10:18 AM
That was the best 5 minutes ever, it works! Many thanks  8)
Title: Re: Super Simple Thread Tags
Post by: iain sherriff on April 04, 2015, 06:10:22 AM
This is probably the most appreciated (by my users) mod I have  :)
Also looking forward to integration that 420 requested  ;)
Title: Re: Super Simple Thread Tags
Post by: 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.
Title: Re: Super Simple Thread Tags
Post by: WadaNon on April 11, 2015, 08:14:48 PM
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.
Title: Re: Super Simple Thread Tags
Post by: 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.
Title: Re: Super Simple Thread Tags
Post by: 420Connect.co.uk on April 25, 2015, 09:49:11 AM
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 :)
Title: Re: Super Simple Thread Tags
Post by: gorbi on April 26, 2015, 05:33:31 AM
Why do  you not use an established symbol # to denote tags?
Title: Re: Super Simple Thread Tags
Post by: Rain Forest on April 26, 2015, 06:10:35 AM
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 :)
Title: Re: Super Simple Thread Tags
Post by: gorbi on April 26, 2015, 07:09:07 AM
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
Title: Re: Super Simple Thread Tags
Post by: Rain Forest on April 26, 2015, 01:26:19 PM
Let's wait for WadaNon, maybe he will support it within one of the next versions :)
Title: Re: Super Simple Thread Tags
Post by: gorbi on April 27, 2015, 12:18:17 AM
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  ;)
Title: Re: Super Simple Thread Tags
Post by: gorbi on April 27, 2015, 05:56:27 AM
You will be able to share posts on social networks at once with #tags
Title: Re: Super Simple Thread Tags
Post by: 420Connect.co.uk on August 08, 2015, 03:28:53 AM
Just wondered if this was still being supported/developed by Wada..
Title: Re: Super Simple Thread Tags
Post by: 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 ? 
Title: Re: Super Simple Thread Tags
Post by: 420Connect.co.uk on August 11, 2015, 03:06:05 PM
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! ;)
Title: Re: Super Simple Thread Tags
Post by: 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?
Title: Re: Super Simple Thread Tags
Post by: WadaNon on August 21, 2015, 03:27:53 AM
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.
Title: Re: Super Simple Thread Tags
Post by: 420Connect.co.uk on August 22, 2015, 04:39:00 PM
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?  ???
Title: Re: Super Simple Thread Tags
Post by: WadaNon on August 22, 2015, 05:21:23 PM
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 ;)
Title: Re: Super Simple Thread Tags
Post by: 420Connect.co.uk on August 22, 2015, 05:34:15 PM
 ;) No worries and thanks again!
Title: Re: Super Simple Thread Tags
Post by: 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....
Title: Re: Super Simple Thread Tags
Post by: WadaNon on August 25, 2015, 02:07:18 AM
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.
Title: Re: Super Simple Thread Tags
Post by: GenesisMUGEN on August 25, 2015, 10:05:14 AM
Sure thing. I had assumed it was the theme.

Title: Re: Super Simple Thread Tags
Post by: WadaNon on August 25, 2015, 10:19:37 AM
Here you go.
/me
Title: Re: Super Simple Thread Tags
Post by: GenesisMUGEN on August 25, 2015, 09:43:58 PM
Awesome! Thank you so much.

You have no idea how perfect this mod is for my site :P
Title: Re: Super Simple Thread Tags
Post by: 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. :)
Title: Re: Super Simple Thread Tags
Post by: WadaNon on September 04, 2015, 10:35:25 AM
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) >_>
Title: Re: Super Simple Thread Tags
Post by: 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.
Title: Re: Super Simple Thread Tags
Post by: d3vcho on September 05, 2015, 12:25:59 PM
Succesfully tested on my forum and it's very nice.

Congratulations.
Title: Re: Super Simple Thread Tags
Post by: WadaNon on September 06, 2015, 12:28:25 AM
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];
Title: Re: Super Simple Thread Tags
Post by: 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?
Title: Re: Super Simple Thread Tags
Post by: 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
Title: Re: Super Simple Thread Tags
Post by: WadaNon on September 20, 2015, 02:22:46 AM
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.
Title: Re: Super Simple Thread Tags
Post by: GenesisMUGEN on September 20, 2015, 02:48:07 AM
That was easy. Thanks!
Title: Re: Super Simple Thread Tags
Post by: crazyASD on February 20, 2016, 06:48:19 PM
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');
Title: Re: Super Simple Thread Tags
Post by: acsieben on June 24, 2016, 07:40:19 PM
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!