vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   calling a file (https://vborg.vbsupport.ru/showthread.php?t=234850)

Satviewers 02-03-2010 12:07 AM

calling a file
 
Hi,

Trying to load a file within the vbulletin page.

PHP Code:

<?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:
PHP Code:

ob_start();
include(
'./shopp.php');
$includeshopbody ob_get_contents();
ob_end_clean(); 

My template is oscShop
Code:

PHP 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 Code:

<?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

Code:

$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:

PHP Code:

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 Code:

<?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($_shop0$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:
PHP Code:

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:
PHP 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.


All times are GMT. The time now is 07:23 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01742 seconds
  • Memory Usage 1,780KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code_printable
  • (8)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (9)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete