Jump to content

Create topic

Featured Replies

Posted

Hello,

is there any way to create a topic except via the REST API? I checked the internals and the part about "Content Items" but however I seem to be too bad at PHP to get it done.

Best Regards

are you wanting to create it via the rest api or inside the framework like from another app?

Pages and Downloads both have the capability of creating a topic (depending upon AdminCP settings). You could copy the general approach from one of those apps.

6 hours ago, Niko Belger said:

Hello,

is there any way to create a topic except via the REST API? I checked the internals and the part about "Content Items" but however I seem to be too bad at PHP to get it done.

Best Regards

 

2 minutes ago, bfarber said:

Pages and Downloads both have the capability of creating a topic (depending upon AdminCP settings). You could copy the general approach from one of those apps.

Example from Downloads app:

			/* Create topic */
			try
			{
				$forum = \IPS\forums\Forum::load( $this->container()->forum_id );
			}
			catch( \OutOfRangeException $e )
			{
				return;
			}
			
			$topic = \IPS\forums\Topic::createItem( $this->author(), $this->ipaddress, \IPS\DateTime::ts( $this->submitted ), $forum, $this->hidden() );
			$title = $this->container()->_topic_prefix . $this->name . $this->container()->_topic_suffix;
			\IPS\Member::loggedIn()->language()->parseOutputForDisplay( $title );
			$topic->title = $title;
			$topic->topic_archive_status = \IPS\forums\Topic::ARCHIVE_EXCLUDE;
			$topic->save();

			if ( \IPS\Settings::i()->tags_enabled )
			{
				$topic->setTags( $this->prefix() ? array_merge( $this->tags(), array( 'prefix' => $this->prefix() ) ) : $this->tags() );
			}
			
			/* Create post */
			$content = \IPS\Theme::i()->getTemplate( 'submit', 'downloads', 'front' )->topic( $this );
			\IPS\Member::loggedIn()->language()->parseOutputForDisplay( $content );
			$post = \IPS\forums\Topic\Post::create( $topic, $content, TRUE, NULL, NULL, $this->author() );
			$topic->topic_firstpost = $post->pid;
			$topic->save();
			
			/* Update file */
			$this->topicid = $topic->tid;
			$this->save();

 

  • Author

Thank you! You saved me once more again.

 

Archived

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

Recently Browsing 0

  • No registered users viewing this page.