vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   include php file (https://vborg.vbsupport.ru/showthread.php?t=135715)

wIrEs 01-06-2007 05:13 PM

include php file
 
is there an easy way to do this? been trying to include a php on vbulletin 3.6.4 on a custom page but it doesn't work. Howto?

Tuk4 01-06-2007 07:55 PM

Hmmz... people should explain themselfs better then this.
If Im not misunderstanding you, then what you are trying to do, is adding new costum php file, which will be integreted with the forum itself.

Its easy, include, Global.php (so you'll have vB Functions - DB, etc') and just link it from the board, that way you can use, templates, pharses etc'.. (Not Hooks tho - as far as i know)

Greets,

hjs146 01-06-2007 09:22 PM

To include something in a template file (custom page), follow these steps:
Step 1, create a variable for the include file:

Open global.php

Find:
PHP Code:

// #############################################################################
// Start initialisation
require_once(CWD '/includes/init.php'); 

Before add:
PHP Code:

ob_start();
include(
'/path/to/file/');
$yourvariable ob_get_contents();
ob_end_clean(); 

Save global.php

Step 2, add $yourvariable to your template file (custom page) through Styles Manager:
Code:

Content Here
$yourvariable
Content Here

That is how you can include stuff in a template file.

wIrEs 01-07-2007 09:05 AM

thank you, i fixed the problem another way, i went the plugin way, i create a plugin with global start the following inside:

PHP Code:

ob_start(); 
include(
'/path/to/file/'); 
$yourvariable ob_get_contents(); 
ob_end_clean(); 

then i just added the variable to the template called by custom page. I guess my problem was that i didn't named the variable properly in the template, i dont remember, it works now, i had given up what i was doing because it was not working but after your post i just tried again and it worked. :alien:

ragtek 01-07-2007 09:52 AM

when you use this just in the custom page, you could built the code into your php file
so it must not be on every page includet like you do it now(overload)

wIrEs 01-07-2007 06:56 PM

by this do you mean the code i posted? what code and which php file?

custom page mypage.php -> plugin -> index.php

ragtek 01-08-2007 07:27 PM

something like
https://vborg.vbsupport.ru/showthrea...79#post1153579

wIrEs 01-10-2007 01:47 AM

thanks for that link, here's what i have so far.

custom_page.php looks like this:

PHP Code:

<?php

// ####################### SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);

// #################### DEFINE IMPORTANT CONSTANTS #######################
define('NO_REGISTER_GLOBALS'1);
define('THIS_SCRIPT''custom_page'); // 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(
    
'custom_template',
);

// pre-cache templates used by specific actions
$actiontemplates = array(

);

// ######################### REQUIRE BACK-END ############################
require_once('./global.php');

// #######################################################################
// ######################## START MAIN SCRIPT ############################
// #######################################################################

$navbits = array();
$navbits[$parent] = 'Viewing Custom Page';

$navbits construct_navbits($navbits);
eval(
'$navbar = "' fetch_template('navbar') . '";');
eval(
'print_output("' fetch_template('custom_template') . '");');

?>


custom_template looks like this:

HTML Code:

$stylevar[htmldoctype]
<html dir="$stylevar[textdirection]" lang="$stylevar[languagecode]">
<head>
<title>$vboptions[bbtitle]</title>
$headinclude
</head>

<body>
$header

$navbar

<table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" border="0" width="100%" align="center">
<tr>
        <td class="tcat">$vbphrase[custom_header]</td>
</tr>
<tr>
        <td class="alt1">$my_included_php_file</td>
</tr>
</table>

$footer
 </body>
</html>

my_included_php_file plugin looks like this:

PHP Code:

ob_start(); 
include(
'C:\Program Files\EasyPHP1-8\www\custom\index.php');
$my_included_php_file ob_get_contents(); 
ob_end_clean(); 

my custom\index.php file looks like this:

PHP Code:

<?php
echo 'hey, vBulletin rox!';
?>

Can you please explain me what i should do now?
do you mean i should put custom_page.php code inside custom\index.php then i should delete the plugin instead? then just to create a navbar link to custom\index.php?

thank you

noppid 01-10-2007 04:36 PM

Do the work of the include file in the custom page file before the template eval.

PHP Code:

ob_start(); 
include(
'C:\Program Files\EasyPHP1-8\www\custom\index.php');
$my_included_php_file ob_get_contents(); 
ob_end_clean();  
eval(
'print_output("' fetch_template('custom_template') . '");'); 

and be done with it. No need for a hook it appears.

wIrEs 01-13-2007 03:25 PM

thank you.

noppid 01-13-2007 03:37 PM

Let us know how things work out for ya and what worked.

Thanks

wIrEs 01-13-2007 05:31 PM

Everything seems to work, i just need to add some new options and make some code changes and some more..


All times are GMT. The time now is 04:52 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.01277 seconds
  • Memory Usage 1,760KB
  • 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
  • (1)bbcode_html_printable
  • (7)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (12)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