View Full Version : calling a file
Satviewers
02-03-2010, 12:07 AM
Hi,
Trying to load a file within the vbulletin page.
<?php
// ####################### SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);
// #################### DEFINE IMPORTANT CONSTANTS #######################
define('THIS_SCRIPT', 'oscShop');
//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('oscShop',
);
// 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('' => 'osc Shopping Cart'));
$navbar = render_navbar_template($navbits);
// ###### YOUR CUSTOM CODE GOES HERE #####
$pagetitle = 'osc Shopping Cart';
$oscShopp = include('shopp.php');
// ###### NOW YOUR TEMPLATE IS BEING RENDERED ######
$templater = vB_Template::create('oscShop');
$templater->register_page_templates();
$templater->register('navbar', $navbar);
$templater->register('pagetitle', $pagetitle);
$templater->register('oscShopp', $oscShopp);
print_output($templater->render());
?>
Is there a way I can get it to load within the vbulletin page.
At the moment it is loading above the header.
Thanks.
BBR-APBT
02-04-2010, 12:35 AM
Search the forums for ob_start(); and you will find exactly what you need.
Satviewers
02-04-2010, 02:52 PM
Thanks for the help.
I created a plugin called shop123.
Hook Location is gobal_start
Code in the plugin is:
ob_start();
include('./shopp.php');
$includeshopbody = ob_get_contents();
ob_end_clean();
My template is oscShop
Code:
{vb:stylevar htmldoctype}
<html xmlns="http://www.w3.org/1999/xhtml" dir="{vb:stylevar textdirection}" lang="{vb:stylevar languagecode}" id="vbulletin_html">
<head>
<title>{vb:raw vboptions.bbtitle} - {vb:raw pagetitle}</title>
{vb:raw headinclude}
</head>
<body>
{vb:raw header}
{vb:raw navbar}
{vb:raw includeshopbody}
{vb:raw footer}
</body>
</html>
My shop.php
<?php
// ####################### SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);
// #################### DEFINE IMPORTANT CONSTANTS #######################
define('THIS_SCRIPT', 'oscShop');
//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('oscShop',
);
// 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('' => 'osc Shopping Cart'));
$navbar = render_navbar_template($navbits);
// ###### YOUR CUSTOM CODE GOES HERE #####
$pagetitle = 'osc Shopping Cart';
// ###### NOW YOUR TEMPLATE IS BEING RENDERED ######
$templater = vB_Template::create('oscShop');
$templater->register_page_templates();
$templater->register('navbar', $navbar);
$templater->register('pagetitle', $pagetitle);
print_output($templater->render());
?>
But it is still not outputting my php file shopp.php.
Have I missed something here.
BBR-APBT
02-04-2010, 04:37 PM
$templater->register('includeshopbody', $includeshopbody);
Satviewers
02-04-2010, 05:04 PM
Thanks again, that fixed it.
I have the plugin "Hook Location is gobal_start" with this:
if (THIS_SCRIPT == 'oscShop')
{
ob_start();
include('./shopp.php');
$includeshopbody = ob_get_contents();
ob_end_clean();
}
If I want to load another php page called address_book.php, do I have to create all these again e.g. template, plugin and php file, so that the new page will load within vbulletin.
BBR-APBT
02-05-2010, 02:15 AM
The same process as above. Just make sure none of your vars are the same thing
Satviewers
02-17-2010, 12:44 AM
I am trying to call a file to show in the admincp.
In my admincp/configuration.php in have:
<?php
// ####################### SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);
// #################### DEFINE IMPORTANT CONSTANTS #######################
$_shopfile = basename($_SERVER['SCRIPT_FILENAME'], '.php');
if (($pos = strrpos($_shopfile, '.')) !== false) {$_shopfile = substr($_shop, 0, $pos);}
define('THIS_SCRIPT', 'osc_' . $_shopfile);
//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('oscShop_admin',
);
// 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('' => 'osc Shopping Cart'));
$navbar = render_navbar_template($navbits);
// ###### YOUR CUSTOM CODE GOES HERE #####
$pagetitle = 'osc Shopping Cart';
// ###### NOW YOUR TEMPLATE IS BEING RENDERED ######
$templater = vB_Template::create('oscShop_admin');
$templater->register_page_templates();
$templater->register('navbar', $navbar);
$templater->register('pagetitle', $pagetitle);
$templater->register('includeshopbody', $includeshopbody);
print_output($templater->render());
?>
I created a plugin called oscShop Body Admin.
Hook Location is gobal_start
Code in the plugin is:
if (THIS_SCRIPT == 'osc_configuration')
{
ob_start();
include('./packages/shop/admin/configuration.php');
$includeshopbody = ob_get_contents();
ob_end_clean();
}
My template is oscShop_admin
Code:
{vb:raw includeshopbody}
If I move the file configuration.php from the admincp directory to the root directory it works in Admin Control Panel when selected.
But if it is in the admincp directory it shows nothing in the Admin Control Panel when selected.
Marco van Herwaarden
02-17-2010, 11:42 AM
Your problem is that you are trying to mix admin and front-end functions. AdminCP scripts do not use the template engine and the version of global.php in the admincp directory is only a limited copy of the version in the forumhome directory. Hence why it does work when placed outside of the admincp directory.
Satviewers
02-17-2010, 11:47 AM
Is there any other way I can get it to call the file.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.