News:

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

Main Menu

Tagging System For Topics

Started by SMFHacks.com Team, December 19, 2006, 10:59:20 AM

Previous topic - Next topic

raklet

Viulian is right.  There is a bug in 1.1.1 that allows duplicate tags when they are entered through Post.php rather than Tags.php

Tags.php contains the line

$tag = htmlspecialchars(trim($_REQUEST['tag']),ENT_QUOTES);


White space is trimmed out of the beginning and end of the string, but no allowance is made for this in Post.php.  The code reads:

$tags = explode(',',htmlspecialchars($_REQUEST['tags'],ENT_QUOTES));


Try the following example.  Go to the end of an existing topic and click on Add Tag.  Enter the following multiple tags:

test
hi
dream

Now, start a brand new topic and enter the following tags separated by comma:

test, hi, dream

Now, go to the tags page and you will see: test hi dream test hi dream.  There are duplicates of the tags because whitespace was not trimmed out of the comma delimited string.  Sure, you could insist that the users enter a comma delimited string in the form of:

test,hi,dream

but not many people are going to remember to do this, nor is it natural to do that.  Viulian's code that he offered in his post fixes these problems and also addresses upper vs lower case (or mixed case) tags - test, Test, tEst would all be recorded as separate tags in the database.  Better to cause the data to be trimmed and uniform in appearance before submitting it to the database.

Thanks for a great module!

Sabre™

Nice mod.
Thanks mate :)


Quote from: edi67 on November 13, 2008, 05:43:41 PM
.......TAGS are all near and words are in confusion , users cannot read them better, may be adding space around words.......
Quote from: edi67 on November 14, 2008, 09:45:59 AM
solved my problem....

edi67, can you share how you did this please :)

Thank you
Do NOT give admin and/or ftp details to just anybody, see if they are trust worthy first!!  Do your homework ;)


raklet

One solution:

In tags.php look for


    // perhaps adjust this title attribute for the things that are tagged
   $context['poptags'] .= ' title="'.$value.' things tagged with '.$key.'"';
   $context['poptags'] .= '>'.$key.'</a> ';


Right after the last line of the above code, you could add something like this:


$context['poptags'] .= 'whatever you want to separate words goes here';


Hth,

Raklet

glennk

Ive noticed duplicate tags on my forum which is really bad as I use tags to link into the forum from my main website when people are wanting to look at topics on a set subject.

For example in my kayak fishing section I use the tags to link to all forum topics on kayak fishing. The problem is there seems to be 2 sets of tags for this keyword.

http://www.whitbyseaanglers.co.uk/forum/index.php?action=tags;tagid=139

http://www.whitbyseaanglers.co.uk/forum/index.php?action=tags;tagid=83

How can I put this right please ??


raklet

Quote from: glennk on November 18, 2008, 08:55:06 AM
Ive noticed duplicate tags on my forum which is really bad as I use tags to link into the forum from my main website when people are wanting to look at topics on a set subject.

How can I put this right please ??



Read Viulian's post here.  More than likely, you are suffering the same problem.  You can fix your code in the manner that he suggests and can use the SSI to clean up duplicates.  BUT, there remains a problem that Viulian did not address.  He removed duplicate tags from the tags table, but he didn't correct entries in the tags_log table of the database.  If tags are deleted from the tags table that are referenced in the tags_log table then there will be errors.  To address this, you could run another simultaneous query that changes the values in tags_log.

glennk

Thanks for making a post it really is appreciated. I hope you dont find this rude or cheeky as it isnt intended to be. But could you repeat the info as if your talking to a complete novice. I dont understand databses etc so a list of easy steps to follow to correct the problem would be really appreciated.

Will this problem be sorted in the next release ??

pooya

Hi anyway this code can have an option where the tag system ads tags using the title of the board ?

I have an example of this r unning on my joomla.

raklet

Quote from: glennk on November 18, 2008, 09:24:50 AM
Thanks for making a post it really is appreciated. I hope you dont find this rude or cheeky as it isnt intended to be. But could you repeat the info as if your talking to a complete novice. I dont understand databses etc so a list of easy steps to follow to correct the problem would be really appreciated.

Will this problem be sorted in the next release ??

Not a problem.  I didn't know what your technical level was.  However, I'm not sure I can walk you through this.  You really need to have a basic understanding of php and databases.  Sorry. 

I'm not the developer of the module.  I'm just commenting on it.  I don't know what vbgamer's plans are for the next release.

Sabre™

Quote from: raklet on November 17, 2008, 09:16:41 PM
One solution:

In tags.php look for


    // perhaps adjust this title attribute for the things that are tagged
   $context['poptags'] .= ' title="'.$value.' things tagged with '.$key.'"';
   $context['poptags'] .= '>'.$key.'</a> ';


Right after the last line of the above code, you could add something like this:


$context['poptags'] .= 'whatever you want to separate words goes here';


Hth,

Raklet

Thanks mate, worked a treat :)

+k

Is there a way to make words different colours?
Do NOT give admin and/or ftp details to just anybody, see if they are trust worthy first!!  Do your homework ;)


raklet

Quote from: Sabre™ on November 19, 2008, 02:39:19 AM
Is there a way to make words different colours?

I'm sure there is.  This is what I would do.  Create an array that associates a color with (for example) the top five words.  Then insert that color into the following line


$context['poptags'] .= '<a href="' . $scripturl . '?action=tags;tagid=' . $tags2[$key] . '" style="font-size: '.$size.'%"';


while the code is looping through setting the size.  The color would go in the "style=" section.  I don't have any specific code for this.  It is just the general idea.

Robi052

In error log see this message

Quote

8: Undefined index: smftags_guest
Datoteka: /home/USERNAME/public_html/forum/Sources/Tags.php
Linija: 77


Tags work fine but that message come in log every day

.:{EK}:. Squall

Is there a way to modify this mod so that the Tags only work in a certain board and not the whole forum?

Thanks,
Squall

tyhgdgh

I have a problem when people are making new topics and adding tags

when a user makes a Topic, and add tags, then post it, nothing shows in the tag section of the forum.
Can you help me?

tsmalmbe

Quote from: .:{EK}:. Squall on November 26, 2008, 07:48:32 PM
Is there a way to modify this mod so that the Tags only work in a certain board and not the whole forum?

Thanks,
Squall

+1 for this one.  Any comments?
..:: http://www.kontrollrummet.com - Studio och musik ::.. RSS?

.HuNTeR.

hi vbgamer45
i have tow questions:
first i combined this mod and Easy Edit Meta Data and did some changes on them
i want to know can i release this as a new mod? or it is better that i give it to you?

second i tried to add a logAction to this mod:

function DeleteTag()
{
global $db_prefix, $ID_MEMBER, $txt;

$id = (int) $_REQUEST['tagid'];
//Check permission
$a_manage = allowedTo('smftags_manage');

$dbresult = db_query("
SELECT
ID_MEMBER,ID_TOPIC,ID_TAG 
FROM {$db_prefix}tags_log
WHERE ID = $id LIMIT 1", __FILE__, __LINE__);

$row = mysql_fetch_assoc($dbresult);
mysql_free_result($dbresult);

if ($row['ID_MEMBER'] != $ID_MEMBER && $a_manage == false)
fatal_error($txt['smftags_err_deletetag'],false);

// Delete the tag for the topic
db_query("DELETE FROM {$db_prefix}tags_log WHERE ID = $id LIMIT 1", __FILE__, __LINE__);

$dbresult = db_query("
SELECT
tag
FROM {$db_prefix}tags
WHERE ID_TAG = $id LIMIT 1", __FILE__, __LINE__);
$row2 = mysql_fetch_assoc($dbresult);
mysql_free_result($dbresult);


// Tag Cleanup
TagCleanUp($row['ID_TAG']);

logAction('Tag Del', array('topic' => $row['ID_TOPIC'], 'Tag' => $row2['tag']));

// Redirect back to the topic
redirectexit('topic=' . $row['ID_TOPIC']);
}


but in logs topics URL saves correctly but tag not displayed
where is problem?
thanks a lot

drroot

How to extend it to support "Tag Topic Alert" by email or PM?

Any topic marked with certain tag then could be alerted by email or private message.

I don't mean notification by already posted topic, but by tag (so any future post with certain tag could be notified).


Thanks.

bullbreedluverz

#336
Quote from: HuNTeR@sm on January 05, 2009, 01:08:43 PM
hi vbgamer45
i have tow questions:
first i combined this mod and Easy Edit Meta Data and did some changes on them
i want to know can i release this as a new mod? or it is better that i give it to you?

That would be a cool mod if it takes the tags and uses them as meta tags for a forum



I could of sworn i seen this mentioned somewhere in this thread but cant find it but how can i change the size of the font for the tags in the cloud?

bullbreedluverz

#337
BUMP - no real support on this mod since NOVEMBER............. not good as its now january


vbgamer45

If you need paid support assistance let me know.

There are settings that control the size of tags under settings
Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

NightBird

#339
Hi, vbgamer ~

Great mod concept, but I'm having some challenges in applying it to the babylon theme for 1.1.7. Creating the button to link to the tag cloud page wasn't any problem, and I did the automated install, then copied the code from the instructions for a manual installation to the babylon theme's index.template.php and display.template.php files.

No errors are hitting with the index.template.php file modified, but I'm getting an error when I copy the code into the babylon theme display.template.php file:


Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in .../Themes/babylon/Display.template.php on line 544

535: <tr><td style="padding: 0 0 1px 0;"></td></tr>
536: </table>
537: <a name="lastPost"></a>
538:
539:
540:
541:
542:
543: // Tagging System
544: echo '<table width="100%" cellpadding="0" cellspacing="0" border="0">545: <tr>
546: <td class="windowbg">
547: <b>', $txt['smftags_topic'], '</b>';
548:


Without the display.template.php edits, I don't see any tags at the bottom of the page the way they appear in the screenshot, and when I edit the top post in a test topic I created with tags I can't see any where that I can edit or add them.

What do I need to do to fix this code for the babylon display.template.php file?


// Tagging System
echo '<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="windowbg">
<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'])
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>

</td>
</tr>
</table>';

//End Tagging System


This will be a great addition to my site if I can get it working so the tags show up and they can be edited later by the thread owner, the admin or a moderator with the proper permission.

Any suggestions would be greatly appreciated.

Thanks!




Edited to add mention that I'd done the initial install through the automated package manager within SMF.

Advertisement: