Niko Belger Posted October 17, 2017 Share Posted October 17, 2017 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 Link to comment Share on other sites More sharing options...
CodingJungle Posted October 17, 2017 Share Posted October 17, 2017 are you wanting to create it via the rest api or inside the framework like from another app? Link to comment Share on other sites More sharing options...
bfarber Posted October 17, 2017 Share Posted October 17, 2017 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. Link to comment Share on other sites More sharing options...
Adriano Faria Posted October 17, 2017 Share Posted October 17, 2017 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(); Link to comment Share on other sites More sharing options...
Niko Belger Posted October 17, 2017 Author Share Posted October 17, 2017 Thank you! You saved me once more again. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.