View Full Version : php file help
TheSupportForum
10-16-2012, 03:59 PM
Hello i have a php file that needs to show
header
content here
footer
navbar
the file is located in /folder1/
which is outside of vbulletin root
i want the page not to load a template, i ust need to include all my customer code within it.
You might want to look at this article (if you haven't already): https://vborg.vbsupport.ru/showthread.php?t=228112 . You say you don't want to use a template, but it might be easiest to make a template that includes the vb header and footer (or copy one of the "top level" vb templates and remove everything between the header and footer), then put something like {vb:raw content} in the middle. Then in your custom script, make all your output a string and set $content to that string, then register theat to the template when rendering it. You could use ob_start()/ob_end_clean() if you wanted. Something like this:
<?php
// ####################### SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);
// #################### DEFINE IMPORTANT CONSTANTS #######################
define('THIS_SCRIPT', 'test');
define('CSRF_PROTECTION', true);
// change this depending on your filename
// ################### PRE-CACHE TEMPLATES AND DATA ######################
// get special phrase groups
$phrasegroups = array();
// get special data templates from the datastore
$specialtemplates = array();
// pre-cache templates used by all actions
$globaltemplates = array('TEST',
);
// pre-cache templates used by specific actions
$actiontemplates = array();
// ######################### REQUIRE BACK-END ############################
// if your page is outside of your normal vb forums directory, you should change directories by uncommenting the next line
// chdir ('/path/to/your/forums');
require_once('./global.php');
// ################################################## #####################
// ######################## START MAIN SCRIPT ############################
// ################################################## #####################
$navbits = construct_navbits(array('' => 'Test Page'));
$navbar = render_navbar_template($navbits);
ob_start();
// Put your customer code here
$contents = ob_get_contents();
ob_end_clean();
// ###### NOW YOUR TEMPLATE IS BEING RENDERED ######
$templater = vB_Template::create('TEST');
$templater->register_page_templates();
$templater->register('navbar', $navbar);
$templater->register('contents', $contents);
print_output($templater->render());
?>
vBulletin® v3.8.12 by vBS, Copyright ©2000-2024, vBulletin Solutions Inc.