PDA

View Full Version : include php file


wIrEs
01-06-2007, 05:13 PM
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:

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


Before add:

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:

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:

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/showthread.php?p=1153579#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

// ####################### 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:

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

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


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