1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Moving all threads within a category to a new location

Discussion in 'XenForo Questions and Support' started by JVCode, Mar 21, 2012.

  1. JVCode

    JVCode Well-Known Member

    Okay, I'm trying to move several thousand threads to a new location from within a category, why am I not just moving them from within the forums? because there's around 1,100 forums within 25 different categories. Is there a way I can do this? either by using the node tree, or even going in via phpmyadmin.

    EDIT: 1 Category, 25 forums, several hundred sub-forums.

    Thanks!
     
  2. Brogan

    Brogan XenForo Moderator Staff Member

    Run this query:
    Code:
    UPDATE xf_thread
    SET node_id = y
    WHERE node_id = x
    Where x is the current node ID and y is the new node ID.

    That will move all threads from one forum to another.
     
    Toxic and Brandon Sheley like this.
  3. ragtek

    ragtek Guest

    and then:

    ACP => Tools => rebuild caches and rebuild the Rebuild Forum Information
     
    aiman.h.kallaf likes this.
  4. JVCode

    JVCode Well-Known Member

    Thanks, already given this method a shot and is doesn't work for my scenario. I have one main forum with around 50 sub-forums attached to it, is there a query where I can say "Okay, move all thread from within the main forum (including all threads from sub-forums) to a new forum."
     
  5. Brogan

    Brogan XenForo Moderator Staff Member

    No, each node has a node ID.
    You will need to to do them all individually.

    It doesn't take long to prepare and run queries, just copy and paste and change the source node ID.
     
    JVCode likes this.
  6. JVCode

    JVCode Well-Known Member

    Oh, I can run multiple queries in one instance? didn't know that, thanks alot :)
     
  7. Brogan

    Brogan XenForo Moderator Staff Member

    Yes, just terminate each line with a ;

    So for example:
    Code:
    UPDATE xf_thread SET node_id = y WHERE node_id = x;
    UPDATE xf_thread SET node_id = y WHERE node_id = x;
    UPDATE xf_thread SET node_id = y WHERE node_id = x;
    UPDATE xf_thread SET node_id = y WHERE node_id = x;
    UPDATE xf_thread SET node_id = y WHERE node_id = x;
    UPDATE xf_thread SET node_id = y WHERE node_id = x;
     
    aiman.h.kallaf and JVCode like this.
  8. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    I think you need this query:

    Code:
    UPDATE xf_thread AS t
    SET t.node_id = X
    WHERE t.node_id IN (
    	SELECT n.node_id
    	FROM xf_node AS n
    	WHERE n.lft BETWEEN Y AND Z
    );
    
    X is the destination node_id.

    Y AND Z are the nested set boundaries for the category which you can see in the xf_node table:

    Screen shot 2012-03-21 at 3.20.55 AM.png

    This query will move every thread from every forum underneath that category if you specify the nested set bounds of the category.

    Backup first.
     
    aiman.h.kallaf likes this.
  9. ragtek

    ragtek Guest

    you can also run
    UPDATE xf_thread SET node_id = y WHERE node_id in ( a,b,c);
     
    aiman.h.kallaf likes this.

Share This Page