Invision Community 4: SEO, prepare for v5 and dormant account notifications Matt November 11, 2024Nov 11
Posted October 17, 20177 yr 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
October 17, 20177 yr are you wanting to create it via the rest api or inside the framework like from another app?
October 17, 20177 yr 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.
October 17, 20177 yr 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();
Archived
This topic is now archived and is closed to further replies.