phpBB 模板 API 错误

发布于 2024-11-27 18:26:11 字数 3839 浏览 3 评论 0原文

我想添加线程并在 phpBB 中显示消息。 这是我的代码:

<?php
define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
include($phpbb_root_path . 'includes/functions_posting.' . $phpEx);
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
include($phpbb_root_path . 'includes/message_parser.' . $phpEx);

$user->session_begin();
$auth->acl($user->data);


// New Topic Example
$subject = 'TEST: Test topic';
$message = 'This is test message';

$uid = $bitfield = $options = ''; // will be modified by generate_text_for_storage
$allow_bbcode = $allow_urls = $allow_smilies = true;
generate_text_for_storage($text, $uid, $bitfield, $options, $allow_bbcode, $allow_urls, $allow_smilies);

$data = array( 
    // General Posting Settings
    'forum_id'            => 2,    // The forum ID in which the post will be placed. (int)
    'topic_id'            => 0,    // Post a new topic or in an existing one? Set to 0 to create a new one, if not, specify your topic ID here instead.
    'icon_id'            => false,    // The Icon ID in which the post will be displayed with on the viewforum, set to false for icon_id. (int)

    // Defining Post Options
    'enable_bbcode'    => true,    // Enable BBcode in this post. (bool)
    'enable_smilies'    => true,    // Enabe smilies in this post. (bool)
    'enable_urls'        => true,    // Enable self-parsing URL links in this post. (bool)
    'enable_sig'        => true,    // Enable the signature of the poster to be displayed in the post. (bool)

    // Message Body
    'message'            => $message,        // Your text you wish to have submitted. It should pass through generate_text_for_storage() before this. (string)
    'message_md5'    => md5($message),// The md5 hash of your message

    // Values from generate_text_for_storage()
    'bbcode_bitfield'    => $bitfield,    // Value created from the generate_text_for_storage() function.
    'bbcode_uid'        => $uid,        // Value created from the generate_text_for_storage() function.

    // Other Options
    'post_edit_locked'    => 0,        // Disallow post editing? 1 = Yes, 0 = No
    'topic_title'        => $subject,    // Subject/Title of the topic. (string)

    // Email Notification Settings
    'notify_set'        => false,        // (bool)
    'notify'            => false,        // (bool)
    'post_time'         => 0,        // Set a specific time, use 0 to let submit_post() take care of getting the proper time (int)
    'forum_name'        => '',        // For identifying the name of the forum in a notification email. (string)

    // Indexing
    'enable_indexing'    => true,        // Allow indexing the post? (bool)

    // 3.0.6
    'force_approved_state'    => true, // Allow the post to be submitted without going into unapproved queue
);
$array = array();
$link = submit_post('post', $subject, '', POST_NORMAL, $array, $data);
//echo $link;

$template->assign_vars(array(
    'MESSAGE_TITLE'   => 'Okay',
    'MESSAGE_TEXT'    => 'Message added! <br /><br /><a href='.$link.'>Go to thread</a>',
   )
);

page_header();
$template->set_filenames(array(
        'body' => 'message_body.html',
));
page_footer();

线程正在创建,但消息没有显示错误:

template->_tpl_load_file(): 文件 message_body.html 不存在或 为空

如果我改变'body' => 'message_body.html', 到 'body' => 'styles/prosilver/template/message_body.html',错误不会改变:

模板->_tpl_load_file():文件 /styles/prosilver/template/message_body.html 不存在或者是 空

哪里出错了?提前致谢。

PS:我来自俄罗斯,很抱歉英语不好。

I want to add thread and show the message in phpBB.
Here is my code:

<?php
define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
include($phpbb_root_path . 'includes/functions_posting.' . $phpEx);
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
include($phpbb_root_path . 'includes/message_parser.' . $phpEx);

$user->session_begin();
$auth->acl($user->data);


// New Topic Example
$subject = 'TEST: Test topic';
$message = 'This is test message';

$uid = $bitfield = $options = ''; // will be modified by generate_text_for_storage
$allow_bbcode = $allow_urls = $allow_smilies = true;
generate_text_for_storage($text, $uid, $bitfield, $options, $allow_bbcode, $allow_urls, $allow_smilies);

$data = array( 
    // General Posting Settings
    'forum_id'            => 2,    // The forum ID in which the post will be placed. (int)
    'topic_id'            => 0,    // Post a new topic or in an existing one? Set to 0 to create a new one, if not, specify your topic ID here instead.
    'icon_id'            => false,    // The Icon ID in which the post will be displayed with on the viewforum, set to false for icon_id. (int)

    // Defining Post Options
    'enable_bbcode'    => true,    // Enable BBcode in this post. (bool)
    'enable_smilies'    => true,    // Enabe smilies in this post. (bool)
    'enable_urls'        => true,    // Enable self-parsing URL links in this post. (bool)
    'enable_sig'        => true,    // Enable the signature of the poster to be displayed in the post. (bool)

    // Message Body
    'message'            => $message,        // Your text you wish to have submitted. It should pass through generate_text_for_storage() before this. (string)
    'message_md5'    => md5($message),// The md5 hash of your message

    // Values from generate_text_for_storage()
    'bbcode_bitfield'    => $bitfield,    // Value created from the generate_text_for_storage() function.
    'bbcode_uid'        => $uid,        // Value created from the generate_text_for_storage() function.

    // Other Options
    'post_edit_locked'    => 0,        // Disallow post editing? 1 = Yes, 0 = No
    'topic_title'        => $subject,    // Subject/Title of the topic. (string)

    // Email Notification Settings
    'notify_set'        => false,        // (bool)
    'notify'            => false,        // (bool)
    'post_time'         => 0,        // Set a specific time, use 0 to let submit_post() take care of getting the proper time (int)
    'forum_name'        => '',        // For identifying the name of the forum in a notification email. (string)

    // Indexing
    'enable_indexing'    => true,        // Allow indexing the post? (bool)

    // 3.0.6
    'force_approved_state'    => true, // Allow the post to be submitted without going into unapproved queue
);
$array = array();
$link = submit_post('post', $subject, '', POST_NORMAL, $array, $data);
//echo $link;

$template->assign_vars(array(
    'MESSAGE_TITLE'   => 'Okay',
    'MESSAGE_TEXT'    => 'Message added! <br /><br /><a href='.$link.'>Go to thread</a>',
   )
);

page_header();
$template->set_filenames(array(
        'body' => 'message_body.html',
));
page_footer();

Thread are creating, but message doesn`t show with an error:

template->_tpl_load_file(): File message_body.html does not exist or
is empty

If i change 'body' => 'message_body.html', to 'body' => 'styles/prosilver/template/message_body.html', error doesn`t changes:

template->_tpl_load_file(): File
/styles/prosilver/template/message_body.html does not exist or is
empty

Where is an error? Thanks in advance.

P.S: I`m from Russia, so sorry for bad English.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

冰魂雪魄 2024-12-04 18:26:11

错误不在于 API - 您缺少 message_body.html 模板文件。根据您当前的样式设置(可能是也可能不是 prosilver),您需要在当前样式的模板文件夹中创建一个名为 message_body.html 的非空白 HTML 文件来解决此错误。

The error is not with the API - You are missing the message_body.html template file. Depending on your current style setting, which may or may not be prosilver, you will need to create a non-blank HTML file named message_body.html in your current style's template folder to resolve this error.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文