• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.
  • This forum is for release discussion only. Discussions that do not relate specifically to the resource release should be discussed in another, more appropriate forum.
  • This forum has been archived. New threads and replies may not be made. All add-ons/resources that are active should be migrated to the Resource Manager. See this thread for more information.

Prevent the "Main Forum" from being created during installation

Brogan

XenForo moderator
Staff member
#1
If, like me, you want to reserve the first x number of node IDs for categories, here's how to stop the "Main Forum", which has a node ID of 2, from being created during installation.

This might seem an odd thing to do at first, but categories are the only node type for which you can't (currently?) define a URL Portion/Stub and as such, the node id is always appended to the URL, for example: http://xenforo.com/community/#official-forums.1

Open the following file: library\XenForo\Install\Data\MySql.php

Find the following code around line 1780:
PHP:
$data[] = "
    INSERT INTO xf_node
        (node_id, title, description, node_type_id, parent_node_id, display_order, lft, rgt, depth)
    VALUES
        (1, 'Main Category', '', 'Category', 0, 1, 1, 4, 0),
        (2, 'Main Forum', '', 'Forum', 1, 1, 2, 3, 1)
";

$data[] = "
    INSERT INTO xf_forum
        (node_id, discussion_count, message_count, last_post_id, last_post_date, last_post_user_id, last_post_username)
    VALUES
        (2, 0, 0, 0, 0, 0, '')
";
Replace it with this:
PHP:
$data[] = "
    INSERT INTO xf_node
        (node_id, title, description, node_type_id, parent_node_id, display_order, lft, rgt, depth)
    VALUES
        (1, 'Main Category', '', 'Category', 0, 1, 1, 2, 0)
";
Install the software as normal and after installation, there will now only be 1 node which is the "Main Category", as follows:
category.PNG

Now you can create as many nodes as you want as categories (keeping some for later use as necessary) and the numbering will be sequential.
 

Shadab

Well-known member
#2
The correct values for lft and rgt should be 1 and 2 respectively. I haven't checked if the installer rebuilds these values after each install/upgrade. If it does, you can ignore this post. :)
PHP:
$data[] = "
    INSERT INTO xf_node
        (node_id, title, description, node_type_id, parent_node_id, display_order, lft, rgt, depth)
    VALUES
        (1, 'Main Category', '', 'Category', 0, 1, 1, 2, 0)
";
 
#5
If, like me, you want to reserve the first x number of node IDs for categories, here's how to stop the "Main Forum", which has a node ID of 2, from being created during installation.
I still don't understand why it is important to have plenty of ID's reserved for categories at the beginning :confused: Anyone who can explain it to me?