Posted May 18, 20196 yr Hi, I tried doing \IPS\forums\Topic::create() like you do when creating a post to a topic with \IPS\forums\Topic\Post::create() and it didnt work, I couldnt find the method in the method in the topic class. how can I create a topic? I have the target forum object and the topic content. Thanks
May 18, 20196 yr This example creates from an external folder so disregard the init.php part if you're in the suite.
May 18, 20196 yr \IPS\Content\Item::create() (which \IPS\forums\Topic inherits) creates the form for output, and handles it's submission. If you are trying to create a topic programmatically, then this is the process: /* Create the topic */ $topic = \IPS\forums\Topic::createItem( $author, $ipAddress, $date, $forum ); $topic->title = $title; $topic->save(); /* Create the post */ $content = \IPS\Text\Parser::parseStatic( $content, TRUE, NULL, $author, 'forums_Forums', TRUE, !(bool) $author->group['g_dohtml'] ); $post = \IPS\forums\Topic\Post::create( $topic, $content, TRUE, NULL, \IPS\forums\Topic\Post::incrementPostCount( $forum ), $author, $date ); /* Update the topic */ $topic->topic_firstpost = $post->pid; $topic->save();
May 18, 20196 yr Author 9 minutes ago, Ryan Ashbrook said: \IPS\Content\Item::create() (which \IPS\forums\Topic inherits) creates the form for output, and handles it's submission. If you are trying to create a topic programmatically, then this is the process: /* Create the topic */ $topic = \IPS\forums\Topic::createItem( $author, $ipAddress, $date, $forum ); $topic->title = $title; $topic->save(); /* Create the post */ $content = \IPS\Text\Parser::parseStatic( $content, TRUE, NULL, $author, 'forums_Forums', TRUE, !(bool) $author->group['g_dohtml'] ); $post = \IPS\forums\Topic\Post::create( $topic, $content, TRUE, NULL, \IPS\forums\Topic\Post::incrementPostCount( $forum ), $author, $date ); /* Update the topic */ $topic->topic_firstpost = $post->pid; $topic->save(); what this line does? $content = \IPS\Text\Parser::parseStatic( $content, TRUE, NULL, $author, 'forums_Forums', TRUE, !(bool) $author->group['g_dohtml'] );
May 18, 20196 yr Just now, Gil Ronen said: what this line does? $content = \IPS\Text\Parser::parseStatic( $content, TRUE, NULL, $author, 'forums_Forums', TRUE, !(bool) $author->group['g_dohtml'] ); It parses the content for display in Invision Community. So, any embeds, BB Code, and so on will be properly replaced on the content before it's saved.
May 18, 20196 yr Author 2 hours ago, Ryan Ashbrook said: It parses the content for display in Invision Community. So, any embeds, BB Code, and so on will be properly replaced on the content before it's saved. It worked, Thanks!
Archived
This topic is now archived and is closed to further replies.