Jump to content
DevFuse Forums
Sign in to follow this  

[IPB 2.3.x] API: Topics and Posts


Description

IPB new api to create topics.
With IPB new API there are so many more options to mod authors, with frequently used tasks being much easier to access. One important one is the API: Topics and Posts.
The below code will create my test topic, and redirect me to it automatically.

[code]/*-------------------------------------------------------------------------*/
// Dev Fuse Example - Include and Set API
/*-------------------------------------------------------------------------*/
include_once("sources/api/api_topics_and_posts.php");
$api = new api_topics_and_posts();
$api->ipsclass = &$this->ipsclass;
$api->set_author_by_name("Michael"); /* Use the actual member name not id */
$api->set_post_content("Hello test post."); /* Post */
$api->set_forum_id("2"); /* The forum ID to post in */
$api->set_topic_title("Michaels test post"); /* The topic title */
$api->set_topic_description("Testing"); /* The topic description */
$api->set_topic_state('open'); /* The topic state 'open' or 'closes' to choose from */
$api->create_new_topic();
$this->ipsclass->print->redirect_screen("Redirecting to topic now", "showtopic={$api->topic_id}" );[/code]

Some optional settings

[code]$api->delay_rebuild = 1; /* Choose to delay stats rebuilding */
$api->topic_id; /* Id number of the new topic */[/code]


Recommended Comments

There are no comments to display.

×
×
  • Create New...