XF 2.1 Creating a category node and forum node as a one time activity

asprin

Active member
Just wondering what would be the recommended way of creating a category and forum so that it can used to created threads whenever a custom entity (say Foo) is inserted into the database? Does it go into the Setup file? Is there any sample code that I can look into for reference?


For example, when addon is installed, I would like to have a Category titled "Foo" created and under that a Forum titled "Newly added". This would give me a placeholder to put the threads created via code into these sections.

PHP:
$foo = $this->em()->create('Asprin\FB:Foo');
$foo->title = 'some short text here';
$foo->description = 'some long text here';
$foo->save();

// now that it's inserted, I want to go ahead and create a new thread under the Category/Forum that would have been created as part of addon
 
Solution
Okay, I have found another elegant way of doing this. I've decided to use addon options approach by choosing the following values:

1672764296727.png

Then whenever Foo is created, I'm fetching the value via $this->options() to get the forum node id and using that to create a new thread.
Okay, I have found another elegant way of doing this. I've decided to use addon options approach by choosing the following values:

1672764296727.png

Then whenever Foo is created, I'm fetching the value via $this->options() to get the forum node id and using that to create a new thread.
 
Solution
Top Bottom