Custom PHP Pages

XF2 Addons Custom PHP Pages 1.1.3
This add-on allows the creation of any number of custom PHP pages with or without the XF layout

Compatible versions
2.1, 2.2
This add-on allows the creation of any number of custom PHP pages with or without the XF layout.
A custom page has access to the XF engine's functions, including sessions and permissions.

All custom pages are their PHP script with individual configuration; PHP knowledge is required.
A custom page script can be above, below, or within the XF install folder, with no restrictions.

You can optionally configure any of the following items on a per-page basis:
  • The custom <head> tag items on top of XenForo's defaults (presumably from an external script)
  • The custom page title
  • The custom page content
  • Whether or not to wrap the above content in the XenForo layout
  • Whether or not to include XF's social meta tags for social media content previews
  • Whether or not to show breadcrumbs, and what breadcrumbs to show
Installation Instructions
  1. Install the add-on zip file (this is an add-on package without extra files)
  2. Make a copy of the sample.php script and name it whatever you want
  3. Point the script's XF constant value to your XenForo install folder; the default is DIR
  4. Set the $head and/or $content variables
  5. Adjust the \ScriptsPages\Setup::set parameters (below), and installation is complete
Sample (sample.php)
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);

Parameters
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
]

How to set parameters externally
To set any parameter above from an external script, define the PHP constant SCRIPT_PAGE_{KEY} prior to loading XenForo, i.e.
PHP:
define('SCRIPT_PAGE_CONTENT', '<b>Hello world</b>');
shanruto
Author shanruto
Level
10
2,115 pts
1.1.3 Version
5 Downloads
234 Views
Published
Updated
0.00 star(s) 0 ratings Average Rating (0)
No Tags

More files from shanruto

Customize Your XenForo 2 Community

Custom PHP Pages provides ultimate customization to your XenForo 2 community website! Enjoy powerful features that make your site stand out. Combine this add-on with XenForo 2 styles from our site and kickstart your online community now.

Why Download Our XenForo 2 Add-ons?

  • Easily enhance the quality of your XenForo online community.
  • Expand your XenForo 2 functionality with thousands of unique options.
  • Create unbelieveable user-experiences with advanced features.

Explore Other Resources

Are you looking for something different? Explore our thousands of unique and special XenForo 2 add-ons, available to download right now. shanruto shared this wonderful resource to you for free, so remember to share your appreciation by liking the resource and reviewing it.

Get started today and make your next project truly unique.

Top Bottom