Thoughts on retroactively adding thread tags

0ptima

Well-known member
Now that XF supports thread tags natively, I was thinking about retroactively adding thread tags to all existing threads on my forum. The thread tags would be based on the thread title and would be normalized and would not include words from a stop list. Every thread would be tagged in a one shot automated process.

Do you think the end result would be something that would be useful and of decent quality? Or would this just make a mess of the tags?
 
Very interesting. I dont have Elastic search installed, but I plan to and will re-visit this topic at a later date.
 
I don't think a wholly programmatic approach will work too well, at least if only using a basic approach. If you took this thread, I presume you'd end up with tags:
  • thoughts
  • retroactively
  • adding
  • thread
  • tags
I don't think those tags are necessarily helpful. Maybe "tags" is correct, but you may want "thread tags" instead; the rest seem like noise.
 
I don't like automatic tagging because I don't think it can work good.

But how about adding a tag to all threads in a certain forum? I was thinking about this.
It would be useful on one of my forums.

Can we use a SQL query for this?
 
Can we use a SQL query for this?

No, as there is serialized data

But how about adding a tag to all threads in a certain forum? I was thinking about this.
It would be useful on one of my forums.

The following code worked for me when I tested it on a single thread. You could expand it to loop through all the threads in a forum. Maybe add it to a XF cron and only update threads with no tags?

PHP:
          $xfDb = XenForo_Application::getDb();
  
          $forumid = 10;
         
          $threadid = 1234;
              
        $forum = $xfDb->fetchRow('
            SELECT *
            FROM xf_forum
            WHERE node_id = ?
        ', $forumid);
       
       
            $thread = $xfDb->fetchRow('
            SELECT *
            FROM xf_thread
            WHERE thread_id = ?
        ', $threadid);

       
     
        $tags = "test, tags";
       

        $tagModel = XenForo_Model::create('XenForo_Model_Tag');
       
        $tagger = $tagModel->getTagger('thread');
        $tagger->setContent($threadid)->setPermissionsFromContext($thread, $forum);
       
       
        $tagger->setTags($tagModel->splitTags($tags));

            $errors = $tagger->getErrors();
            if ($errors)
            {
                return $this->responseError($errors);
            }

            $cache = $tagger->save();
 
If you start adding the same tags to all threads in a large node then these tags will become your most popular tags and this is what will always be displayed in your tag cloud. If you are looking for a SEO enhancement then take a closer look.
 
Are tags really worth all that effort? Jeez, I'd need to see some quantifiable, verifiable payoff to sink all that time into tagging existing threads.
 
Top Bottom