Invision Community 4: SEO, prepare for v5 and dormant account notifications By Matt Monday at 02:04 PM
Gil Ronen Posted May 18, 2019 Posted May 18, 2019 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
Adriano Faria Posted May 18, 2019 Posted May 18, 2019 This example creates from an external folder so disregard the init.php part if you're in the suite.
Ryan Ashbrook Posted May 18, 2019 Posted May 18, 2019 \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();
Gil Ronen Posted May 18, 2019 Author Posted May 18, 2019 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'] );
Ryan Ashbrook Posted May 18, 2019 Posted May 18, 2019 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.
Gil Ronen Posted May 18, 2019 Author Posted May 18, 2019 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!
Recommended Posts
Archived
This topic is now archived and is closed to further replies.