$threadprefix = new XenForo_Phrase($prefixModel->getPrefixTitlePhraseName($thread['prefix_id']));
$prefixIds = array_keys($prefixModel->getPrefixesInForum($forumId));
$writer = XenForo_DataWriter::create('XenForo_DataWriter_Discussion_Thread');
$writer->set('user_id', $visitor['user_id']);
$writer->set('username', $visitor['username']);
$writer->set('title', $input['subject']);
$postWriter = $writer->getFirstMessageDw();
$postWriter->set('message', $input['message']);
$writer->set('node_id', $forumId);
$writer->preSave();
$writer->save();
$thread = $writer->getMergedData();
return $this->responseRedirect(
XenForo_ControllerResponse_Redirect::SUCCESS,
$this->getDynamicRedirect(),
new XenForo_Phrase('your_message_has_been_sent')
);
$dw = XenForo_DataWriter::create('XenForo_DataWriter_ThreadPrefix');
if ($prefixId)
{
$dw->setExistingData($prefixId);
}
$dw->bulkSet(array(
'prefix_group_id' => $input['prefix_group_id'],
'display_order' => $input['display_order'],
'css_class' => $input['css_class'],
'allowed_user_group_ids' => $allowedGroupIds
));
$dw->setExtraData(XenForo_DataWriter_ThreadPrefix::DATA_TITLE, $input['title']);
$dw->save();
$this->_getPrefixModel()->updatePrefixForumAssociationByPrefix($dw->get('prefix_id'), $input['node_ids']);
$input = $this->_input->filter(array(
'title' => XenForo_Input::STRING,
'prefix_group_id' => XenForo_Input::UINT,
'display_order' => XenForo_Input::UINT,
'css_class' => XenForo_Input::STRING,
'usable_user_group_type' => XenForo_Input::STRING,
'user_group_ids' => array(XenForo_Input::UINT, 'array' => true),
'node_ids' => array(XenForo_Input::UINT, 'array' => true),
));
$writer = XenForo_DataWriter::create('XenForo_DataWriter_ThreadPrefix');
$writer->set('title', $minTitle);
$writer->set('prefix_group_id', 1);
$writer->set('css_class', 'prefix prefixPrimary');
$writer->set('node_ids', $node_ids);
$writer->preSave();
$writer->save();
The field 'title' was not recognised.
The field 'node_ids' was not recognised.
$writer->set('title', $minTitle);
$writer->set('node_ids', $node_ids);
$writer->setExtraData(XenForo_DataWriter_ThreadPrefix::DATA_TITLE, $minTitle);
$this->_getPrefixModel()->updatePrefixForumAssociationByPrefix($writer->get('prefix_id'), $node_ids);
'prefix_id' => array('type' => self::TYPE_UINT, 'autoIncrement' => true),
'prefix_group_id' => array('type' => self::TYPE_UINT, 'default' => 0),
'display_order' => array('type' => self::TYPE_UINT_FORCED, 'default' => 0),
'materialized_order' => array('typpe' => self::TYPE_UINT_FORCED, 'default' => 0),
'css_class' => array('type' => self::TYPE_STRING, 'maxLength' => 50, 'default' => ''),
'allowed_user_group_ids' => array('type' => self::TYPE_UNKNOWN, 'default' => '',
'verification' => array('$this', '_verifyAllowedUserGroupIds')
$dw->bulkSet(array(
'prefix_group_id' => $input['prefix_group_id'],
'display_order' => $input['display_order'],
'css_class' => $input['css_class'],
'allowed_user_group_ids' => $allowedGroupIds
));
$dw->setExtraData(XenForo_DataWriter_ThreadPrefix::DATA_TITLE, $input['title']);
$this->_getPrefixModel()->updatePrefixForumAssociationByPrefix($dw->get('prefix_id'), $input['node_ids']);
It works but the prefix name is: thread_prefix_4. Where 4 is the prefix_id. Any idea how to set title and node where the prefix is usable?
$threadprefix = new XenForo_Phrase($prefixModel->getPrefixTitlePhraseName($thread['prefix_id']));
public function getPrefixTitlePhraseName($prefixId)
{
return 'thread_prefix_' . $prefixId;
}
That is correct, that is how prefixes are saved.. the titles are saved within phrases
As mentioned, to get this title you will need to use:
Code:$threadprefix = new XenForo_Phrase($prefixModel->getPrefixTitlePhraseName($thread['prefix_id']));
If you look at your phrases and search through them, you will find a bunch of them named:
thread_prefix_1, thread_prefix_2 etc
$dw->setExtraData(XenForo_DataWriter_ThreadPrefix::DATA_TITLE, $input['title']);
We use essential cookies to make this site work, and optional cookies to enhance your experience.