Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
  #1  
Old 02-03-2010, 12:07 AM
Satviewers Satviewers is offline
 
Join Date: Oct 2009
Posts: 58
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default 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.
Reply With Quote
  #2  
Old 02-04-2010, 12:35 AM
BBR-APBT's Avatar
BBR-APBT BBR-APBT is offline
 
Join Date: Feb 2009
Location: Maryland
Posts: 946
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Search the forums for ob_start(); and you will find exactly what you need.
Reply With Quote
  #3  
Old 02-04-2010, 02:52 PM
Satviewers Satviewers is offline
 
Join Date: Oct 2009
Posts: 58
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #4  
Old 02-04-2010, 04:37 PM
BBR-APBT's Avatar
BBR-APBT BBR-APBT is offline
 
Join Date: Feb 2009
Location: Maryland
Posts: 946
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Code:
$templater->register('includeshopbody', $includeshopbody);
Reply With Quote
  #5  
Old 02-04-2010, 05:04 PM
Satviewers Satviewers is offline
 
Join Date: Oct 2009
Posts: 58
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #6  
Old 02-05-2010, 02:15 AM
BBR-APBT's Avatar
BBR-APBT BBR-APBT is offline
 
Join Date: Feb 2009
Location: Maryland
Posts: 946
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

The same process as above. Just make sure none of your vars are the same thing
Reply With Quote
  #7  
Old 02-17-2010, 12:44 AM
Satviewers Satviewers is offline
 
Join Date: Oct 2009
Posts: 58
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #8  
Old 02-17-2010, 11:42 AM
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
Posts: 25,415
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #9  
Old 02-17-2010, 11:47 AM
Satviewers Satviewers is offline
 
Join Date: Oct 2009
Posts: 58
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Is there any other way I can get it to call the file.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 12:20 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04173 seconds
  • Memory Usage 2,284KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)bbcode_code
  • (8)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (9)post_thanks_box
  • (9)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (9)post_thanks_postbit_info
  • (9)postbit
  • (9)postbit_onlinestatus
  • (9)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete