Jump to content

Posting library IPS4


Subzero-mb

Recommended Posts

Posted

Now I am testing IPS4 I want to include some of the functions I used in my website with IPS3. One of them is the possibility to create a new topic outside of IPS suite. With IPS3 was very easy, you just call the topic posting library and give the title, author and message of the topic...

$classToLoad = IPSLib::loadLibrary( IPSLib::getAppDir( 'forums' ) . '/sources/classes/post/classPost.php', 'classPost', 'forums' );
$classToLoad = IPSLib::loadLibrary( IPSLib::getAppDir( 'forums' ) . '/sources/classes/post/classPostForms.php', 'classPostForms', 'forums' );
$this->post = new $classToLoad( $this->registry );

$this->post->setBypassPermissionCheck( true );
$this->post->setIsAjax( true );
$this->post->setPublished( true );
$this->post->setTopicID( 123 );
$this->post->setForumID( 2 );
$this->post->setForumData( $this->registry->class_forums->getForumById( 2 ) );
$this->post->setAuthor( IPSMember::load( 1 ) );
$this->post->setPostContentPreFormatted( "This is the post" );

$post	= $this->post->getPostData();

Now with IPS4 I have not seen yet any documentation related to post in the forum from an external site, so maybe someone can give me an advice about how can I start with this because right now I am lost. WIth an advice it will be more than enough, I am not waiting for someone who make all the job for me but just some information. Many thanks!

 

Posted

I cannot see anything @Kevin Carwile :( Can you post it again?

Captura de pantalla 2015-06-01 a la(s) 19.32.26.png

​It's because the topic he linked to is in the contributer section. I will quote the relevant post for you

            $title = "Something Something";
            $content = "<p>We aint gonna take it!</p>";
            
            $member = \IPS\Member::load( $member_id );

            $forum = \IPS\forums\Forum::load( $forum_id );

            $topic = \IPS\forums\Topic::createItem(
                $member,
                $member->ip_address,
                \IPS\DateTime::ts( time() ),
                $forum
            );

            $topic->title = $title;
            $topic->save();

            $post = \IPS\forums\Topic\Post::create(
                $topic,
                $content,
                TRUE,
                NULL,
                TRUE,
                $member,
                \IPS\DateTime::ts( time() )
            );

            $topic->topic_firstpost = $post->pid;
            $topic->save();

thanks everyone, this seems to effectively reproduce the "posting" function from 3.x :)

Archived

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

  • Recently Browsing   0 members

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