Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions

Reply
 
Thread Tools Display Modes
  #1  
Old 01-06-2007, 05:13 PM
wIrEs wIrEs is offline
 
Join Date: Dec 2006
Posts: 63
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default 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?
Reply With Quote
  #2  
Old 01-06-2007, 07:55 PM
Tuk4 Tuk4 is offline
 
Join Date: Feb 2003
Posts: 19
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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,
Reply With Quote
  #3  
Old 01-06-2007, 09:22 PM
hjs146 hjs146 is offline
 
Join Date: Dec 2006
Posts: 4
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #4  
Old 01-07-2007, 09:05 AM
wIrEs wIrEs is offline
 
Join Date: Dec 2006
Posts: 63
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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:
Reply With Quote
  #5  
Old 01-07-2007, 09:52 AM
ragtek ragtek is offline
 
Join Date: Mar 2006
Location: austria, croatia
Posts: 1,630
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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)
Reply With Quote
  #6  
Old 01-07-2007, 06:56 PM
wIrEs wIrEs is offline
 
Join Date: Dec 2006
Posts: 63
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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

custom page mypage.php -> plugin -> index.php
Reply With Quote
  #7  
Old 01-08-2007, 07:27 PM
ragtek ragtek is offline
 
Join Date: Mar 2006
Location: austria, croatia
Posts: 1,630
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

something like
https://vborg.vbsupport.ru/showthrea...79#post1153579
Reply With Quote
  #8  
Old 01-10-2007, 01:47 AM
wIrEs wIrEs is offline
 
Join Date: Dec 2006
Posts: 63
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply With Quote
  #9  
Old 01-10-2007, 04:36 PM
noppid noppid is offline
 
Join Date: Mar 2003
Location: Florida
Posts: 1,875
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #10  
Old 01-13-2007, 03:25 PM
wIrEs wIrEs is offline
 
Join Date: Dec 2006
Posts: 63
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

thank you.
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 10:53 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.04634 seconds
  • Memory Usage 2,264KB
  • 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
  • (1)bbcode_html
  • (7)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)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
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete