Jump to content
Дизайн и модификация Invision Community IPBSkinsBETA
Search In
  • More options...
Find results that contain...
Find results in...
Sign in to follow this  
HooLIGUN

Создание темы внешним скриптом

Recommended Posts

Посмотрите \system\Content\ItemTopic.php метод syncTopic()

 

Share this post


Link to post
07.11.2020 в 06:33, newbie сказал:

Посмотрите \system\Content\ItemTopic.php метод syncTopic()

 

Приподниму тему. В прошлый раз ладу не дал. Сейчас начал снова разбираться, и всё равно не понял.

Не подскажите, как примерно можно воспользоваться данным методом?

Share this post


Link to post

В этом файле есть пример кода для создания темы через API.

	$forumId = 'ид форума';
	$authorId = 'ид автора';	
	$title   = 'Название темы';
	$content = 'Сообщение';
	
	/* Create topic */
	$forum = \IPS\forums\Forum::load( $forumId );
	$author = \IPS\Member::load( $authorId );

	$topic = \IPS\forums\Topic::createItem( $author, $ipAddress ?? \IPS\Request::i()->ipAddress(), new \IPS\DateTime, $forum );
	$topic->title = $title;
	$topic->topic_archive_status = \IPS\forums\Topic::ARCHIVE_EXCLUDE;
	$topic->save();
	$topic->markRead( $author );

	/* Create post */
	$post = \IPS\forums\Topic\Post::create( $topic, $content, TRUE, NULL, NULL, $author );
	$topic->topic_firstpost = $post->pid;
	$topic->save();
	\IPS\Content\Search\Index::i()->index( $post );

 

  • Upvote 1

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...