XF 2.1 Batch select Tag and remove

Codeless

Active member
Hello
i want to know how can i select multiple Tag and delete them i have approx 52 pages of tags and most of them are useless i want to remove useless tags from forum but there is no option of mass select .

if anyone can provide me a code which can filter data like tags have 2 or 5 letters or mass select and delete i will appricate it

thank you in advance
 
Is there nothing for this?

I've got over 8000 tags and need to do some mass pruning.

From looking in the DB, there is the "tags" table and the "tag_content" table that reference these tags. I tested deleting an entry from the tags table but it didn't also delete references in the tag_content table. So at the least we'd have to delete references from both.

I just don't know if these are the only places where tags are referenced or if there is other cleanup/cache or thread/post cleanups anywhere else.
 
I want to do this, and it seems a complete pain. I want to just keep the most popluar tags, which is about 50 out of 2,500.

So is the only way to click on the dustbin one by one? :cry:
 
if anyone can provide me a code which can filter data like tags have 2 or 5 letters or mass select and delete i will appricate it

If your letters are xyz:

Code:
SELECT * FROM `name_of_database`.`xf_tag` WHERE (CONVERT(`tag_id` USING utf8) LIKE '%xyz%' OR CONVERT(`tag` USING utf8) LIKE '%xyz%' OR CONVERT(`tag_url` USING utf8) LIKE '%xyz%' OR CONVERT(`use_count` USING utf8) LIKE '%xyz%' OR CONVERT(`last_use_date` USING utf8) LIKE '%xyz%' OR CONVERT(`permanent` USING utf8) LIKE '%xyz%')
 
I figured out how to do this with a bit of PHP. You will have to figure out how to put this into a custom plugin or somewhere where you can run it properly. I can't provide the overall code I used because it originated as a paid tool. I only adapted part of a controller to run this.

PHP:
// Grab all the tags in the system
$finder = \XF::finder('XF:Tag');
$allTags = $finder->fetch();
// Count them if you want to output that, but this isn't needed.
$count = count($allTags);

// Loop over them and delete any that have equal or less than 10 uses
foreach ($allTags as $tag) {
  if ($tag->use_count <= 10)
    $tag->delete();
}

There is no output or progress bar, so when this code runs, that's it, those tags will be deleted. It's relatively fast. On my system it deleted over 8,000 tags and only took seconds.

You can adapt the code to check whatever you like, I only checked use_count but if you output the $tag object you can see other properties. You can certainly check the string length and delete short tags as well.
 
If your letters are xyz:

Code:
SELECT * FROM `name_of_database`.`xf_tag` WHERE (CONVERT(`tag_id` USING utf8) LIKE '%xyz%' OR CONVERT(`tag` USING utf8) LIKE '%xyz%' OR CONVERT(`tag_url` USING utf8) LIKE '%xyz%' OR CONVERT(`use_count` USING utf8) LIKE '%xyz%' OR CONVERT(`last_use_date` USING utf8) LIKE '%xyz%' OR CONVERT(`permanent` USING utf8) LIKE '%xyz%')
OK, well I can do it fairly quickly via the database xf_tag
Looks like this deletes the tags, but not the links to them in threads :(
 
My script only deletes tags used less than 10 times so even if there are a few odd uses visible, they will be few. But then again, maybe deleting them to way I did automatically removes from posts?
 
Found add-on for batch updating tags for XF 1:

Anybody have similar solution for XF 2?
 
Found add-on for batch updating tags for XF 1:

Anybody have similar solution for XF 2?
Still looking but haven't found anything
 
Update on this is that I have tested delete all tags. Seems to work but I
Looks like this deletes the tags, but not the links to them in threads :(
OK I finally found a way (I think) to delete all tags and references to them. It seems to work but use at your own peril and test first. Don't blame me if it breaks anything.

This is what I did:

Delete all rows from the tables: xf_tag and xf_tag_content

There was nothing in xf_tag_result_cache so I left that alone.

But then to get rid of all references in threads I needed to empty the tags column in xf_thread:

UPDATE xf_thread set tags =''

I still really wish this could be done from ACP
 
Back
Top Bottom