自定义PHP页面

自定义PHP页面 1.2.2

没有下载权限
XF 兼容性
  1. 2.3.x
  2. 2.2.x
摘要
Create custom PHP pages with or without XF layout using this add-on. Access XF engine functions like sessions and permissions. Customize head tags, titles, content, and more per page for enhanced user experience. No restrictions on script location; flexible configuration options available.
这个插件允许创建任意数量的自定义PHP页面,既可以使用XenForo布局,也可以不使用。
自定义页面可以访问XenForo引擎的功能,包括会话和权限。

所有自定义页面都是独立的PHP脚本,并且具有各自的配置;需要PHP知识。

自定义页面脚本可以在XenForo安装文件夹之上、之下或其中任何位置,没有限制。

您可以根据每页的需求配置以下项目:

- 在XenForo默认基础上添加自定义<head>标签项
- 自定义页面标题
- 自定义页面内容
- 是否在XenForo布局上方包裹上述内容
- 是否包含XenForo的社交元标签以供社交媒体内容预览使用
- 是否显示面包屑导航,以及要显示哪些面包屑

安装说明:

1. 安装插件压缩包(这是一个不带额外文件的插件包)
2. 复制sample.php脚本并重命名为您想要的名字
3. 将脚本中的XenForo常量值指向您的XenForo安装文件夹;默认为DIR
4. 设置$head和/or$content变量
5. 调整\ScriptsPages\Setup::set参数(以下),安装完成
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);
参数
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 
    'content' => null, // the page content; this is required
    'raw' => false // whether or not to remove the XenForo layout
]
如何从外部脚本设置参数

要从外部脚本设置任何上述参数,需在加载XenForo之前定义PHP常量SCRIPT_PAGE_{KEY},即:
代码:
define('SCRIPT_PAGE_CONTENT', '<b>Hello world</b>');
作者
axtona
浏览
381
扩展类型
zip
文件大小
23.5 KB
首次发布
上次更新
评分 0.00 星 0 个评分
链接失效了吗? 发送消息 给 NP 团队,我们会尽快为您处理!
支持开发者 如果您对测试满意或项目已成功盈利,可点击「更多信息」按钮,通过购买来支持开发者!

最新更新

  1. 1.2.2 - changelog
    Fixed major bug causing custom breadcrumb and title parameters to be ignored. Changed minimum PHP version from implicit 8.0 to explicit 7.1.
  2. 1.2.1 - changelog
    Fixed InvalidArgumentException error.
  3. 1.1.5 - changelog
    Fixed bug that was preventing XF 2.3 compatibility.

来自 axtona 的更多资源

Relevio.ai A
Relevio.ai 1.0.0
这是一个针对XenForo的Relevio插件,它是一个独特的上下文感知、规则驱动的内容管理引擎
AI 论坛BOT A
AI 论坛BOT 1.1.1
论坛bot给你一个训练在你论坛自身内容上的.bot
Persona - 个性化你的论坛身份 A
Persona为论坛上的每一个成员提供了工具,让他们能够打造自己的存在感。
返回
顶部