Jump to content

Creating a topic


Gil Ronen

Recommended Posts

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

Link to comment
Share on other sites

\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();

 

Link to comment
Share on other sites

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'] );
 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...