这个附加组件允许创建任意数量的带有或不带有XF布局的自定义PHP页面。
自定义页面可以访问XF引擎的功能,包括会话和权限。
所有自定义页面都是自己的PHP脚本,具有单独的配置; 需要PHP知识。
自定义页面脚本可以在XF安装文件夹的上方,下方或内部,没有任何限制。
您可以选择按页配置以下任何项目:
- 在XenForo的默认顶部的自定义 <head> 标记项 (可能来自外部脚本)
- 自定义页面标题
- 自定义页面内容
- 是否在XenForo布局中包装上述内容
- 是否在社交媒体内容预览中包含XF的社交元标签
- 是否显示面包屑,以及要显示哪些面包屑
安装说明
- 安装附加zip文件 (这是一个没有额外文件的加载包)
- 制作sample.php脚本的副本,并将其命名为任何你想要的
- 指向脚本的XF常量值添加到XenForo安装文件夹; 默认值为方向
- 设置 $ head和/或 $ content变量
- 调整 \ ScriptsPages \ Setup::set参数 (如下所示),安装完成
[CODE lang="php" title="示例 (Sample.php)"]<?php
// Set PHP Reporting
error_reporting(E_ALL & ~E_NOTICE);
define('
XF',
DIR); // EDIT VALUE IF SCRIPT IS NOT IN XF FOLDER
require
XF . '/src/XF.php';
XF::start(
XF);
\ScriptsPages\Setup::set('init', true);
$app = \XF::setupApp('XF\Pub\App');
$app->start();
$request = $app->request();
// EDIT BELOW to set the page's $head and/or $content; the code below is a sample
/** ob_start();
require_once
DIR . DIRECTORY_SEPARATOR . pathinfo(
FILE, PATHINFO_FILENAME) . "-head.php";
$head = ob_get_contents();
ob_end_clean(); **/
/** ob_start();
require_once
DIR . DIRECTORY_SEPARATOR . pathinfo(
FILE, PATHINFO_FILENAME) . "-content.php";
$content = ob_get_contents();
ob_end_clean(); */
// EDIT BELOW TO CONFIGURE
\ScriptsPages\Setup::set([
'breadcrumbs' => ['Item 1' => '/1', 'Item 2' => '/2', 'Item 3' => '/3'],
'head' => $head,
'content' => $content
]);
// STOP HERE
$app->run()->send($request);[/CODE]
参数
PHP:
[
'navigation_id' => null, // the navigation tab to highlight
'head' => null, // code to embed inside the <head> tag
'metadata' => true, // include social media meta tags like 'og:*' for social media previews
'title' => null, // the page title; if null, falls back to board title
'breadcrumbs' => true, // true to include breadcrumbs, false to not, or an array of [name => href, ...]
'content' => null, // the page content; this is required
'raw' => false // whether or not to remove the XenForo layout
]
如何在外部设置参数
要从外部脚本设置上述任何参数,请定义PHP常量
SCRIPT_PAGE_{KEY}
在装载XenForo之前,即
PHP:
define('SCRIPT_PAGE_CONTENT', '<b>Hello world</b>');