Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 04-16-2010, 02:46 PM
NickyDee NickyDee is offline
 
Join Date: Aug 2008
Posts: 53
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default PHP in vB4 template

Hey,

I want to include a php file which generates a list (/Forum/statsinner.php) at the bottom of a custom vbulletin page (/Forum/database5yr.php).

To do this I have added an includephp plugin (in global start):

Code:
ob_start();
include('/Forum/statsinner.php');
$includedphp = ob_get_contents();
ob_end_clean();
and then added {vb:raw includedphp} to my custom pages template. (I have also tried global.includedphp)

However - this doesn't seem to be working. Have I done something crazy here? This has really got me stumped, any help would be very much appreciated.
Reply With Quote
  #2  
Old 04-16-2010, 08:07 PM
somoneybaby somoneybaby is offline
 
Join Date: May 2009
Posts: 4
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by NickyDee View Post
Hey,

I want to include a php file which generates a list (/Forum/statsinner.php) at the bottom of a custom vbulletin page (/Forum/database5yr.php).

To do this I have added an includephp plugin (in global start):

Code:
ob_start();
include('/Forum/statsinner.php');
$includedphp = ob_get_contents();
ob_end_clean();
and then added {vb:raw includedphp} to my custom pages template. (I have also tried global.includedphp)

However - this doesn't seem to be working. Have I done something crazy here? This has really got me stumped, any help would be very much appreciated.
I'm completely stumped as well. I am doing something similar and I'm getting nothing. In earlier versions of vB, you would just call $includedphp but that doesn't seem to be working either.
Reply With Quote
  #3  
Old 04-16-2010, 08:25 PM
NickyDee NickyDee is offline
 
Join Date: Aug 2008
Posts: 53
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I think the problem we both have is that template/variables need to be pre-registered now whereas in the past they didn't.

But I can't for the life of me figure out where I'm going wrong. I've tried adding this (below) code into both my include PHP and my custom page PHP and still no luck:

Code:
vB_Template::preRegister('cpage_Stats',array('includedphp ' => $includedphp));
Reply With Quote
  #4  
Old 04-16-2010, 08:27 PM
somoneybaby somoneybaby is offline
 
Join Date: May 2009
Posts: 4
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Got it! Let me know if this works for you.

Code:
ob_start();
include('/Forum/statsinner.php');
$includedphp = ob_get_contents();
ob_end_clean();

vB_Template::preRegister('TEMPLATE_NAME_YOU_ARE_ADDING_CALL_INTO', array('includedphp' => $includedphp));
Then in your page template call {vb:raw $includedphp}

My example:

Code:
ob_start();
include("$_VhostPath/html/custom/vbulletin_display_login.php");
$pb_header_include = ob_get_contents();
ob_end_clean();

vB_Template::preRegister('header', array('pb_header_include' => $pb_header_include));
--------------- Added [DATE]1271453321[/DATE] at [TIME]1271453321[/TIME] ---------------

Quote:
Originally Posted by NickyDee View Post
I think the problem we both have is that template/variables need to be pre-registered now whereas in the past they didn't.

But I can't for the life of me figure out where I'm going wrong. I've tried adding this (below) code into both my include PHP and my custom page PHP and still no luck:

Code:
vB_Template::preRegister('cpage_Stats',array('includedphp ' => $includedphp));
Check your call. Are you using {vb:raw $includedphp} instead of what your original post showed {vb:raw includedphp} ?
Reply With Quote
  #5  
Old 04-16-2010, 08:51 PM
NickyDee NickyDee is offline
 
Join Date: Aug 2008
Posts: 53
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Okay, When I got it working, it knocked one of my other custom pages off. The global hook has disabled one of my other custom template pages.

Heres the link and the error code:

I'm not sure but I think maybe its not clearing the object buffering?

As of 13:27 today this is still not working. It seems if I disable my plugin (in the above posts), the page linked above works. If it enable them, i get the error you can see.
Reply With Quote
  #6  
Old 04-19-2010, 05:08 PM
somoneybaby somoneybaby is offline
 
Join Date: May 2009
Posts: 4
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Can you post your statsinner.php code? I'm thinking you are having some conflicts with your SQL queries?
Reply With Quote
  #7  
Old 04-19-2010, 06:04 PM
NickyDee NickyDee is offline
 
Join Date: Aug 2008
Posts: 53
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I think you may be right, heres my statsinner.php code:

PHP Code:
<?php
// ####################### SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);

// #################### DEFINE IMPORTANT CONSTANTS #######################

define('THIS_SCRIPT''Stats');
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('cpage_Statsmain',);

// 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 ('/Forum');
require_once('./global.php');
?>
<script type="text/javascript">
function load() { 
    var urlstring = window.location.href;
    if (urlstring.indexOf("ch1=a") > -1) { document.form1.ch1.checked = true } else { document.form1.ch1.checked = false };
    if (urlstring.indexOf("ch2=b") > -1) { document.form1.ch2.checked = true } else { document.form1.ch2.checked = false };
    if (urlstring.indexOf("ch3=c") > -1) { document.form1.ch3.checked = true } else { document.form1.ch3.checked = false };
    if (urlstring.indexOf("ch4=d") > -1) { document.form1.ch4.checked = true } else { document.form1.ch4.checked = false };
    if (urlstring.indexOf("ch5=e") > -1) { document.form1.ch5.checked = true } else { document.form1.ch5.checked = false };
    if (urlstring.indexOf("ch6=f") > -1) { document.form1.ch6.checked = true } else { document.form1.ch6.checked = false };
}
</script>
<?

if (isset($_GET['Submit1'])) {

    if (isset($_GET['ch1'])) { $ch1 = $_GET['ch1'];
    if ($ch1 == 'a') { $ch1 = 'checked';}
    }
    if (isset($_GET['ch2'])) { $ch2 = $_GET['ch2'];
    if ($ch2 == 'b') { $ch2 = 'checked';}
    }
    if (isset($_GET['ch3'])) { $ch3 = $_GET['ch3'];
    if ($ch3 == 'c') { $ch3 = 'checked';}
    }
    if (isset($_GET['ch4'])) { $ch4 = $_GET['ch4'];
    if ($ch4 == 'd') { $ch4 = 'checked';}
    }
    if (isset($_GET['ch5'])) { $ch5 = $_GET['ch5'];
    if ($ch5 == 'e') { $ch5 = 'checked';}
    }
    if (isset($_GET['ch6'])) { $ch6 = $_GET['ch6'];
    if ($ch6 == 'f') { $ch6 = 'checked';}
    }
}

//select the table

$query="SELECT * FROM medical_school WHERE CourseT = 'UG'";
if ($ch1 == checked) { // Order by resits only
  $query .= " AND Resits = 'Yes'";
} if ($ch2 == checked) { // Order by clearing only
  $query .= " AND Clearing = 'Yes'";
} if ($ch3 == checked) { // Order by biology only
  $query .= " AND Biology = '-'";
} if ($ch4 == checked) { // Order by chemistry only
  $query .= " AND Chemistry = '-'";
} if ($ch5 == checked) { // Order by ukcat only
  $query .= " AND UKCAT = '-'";
} if ($ch6 == checked) { // Order by ukcat only
  $query .= " AND Tests = '-'";}

$result=mysql_query($query);

$num=mysql_numrows($result);

mysql_close(); ?>

<div style="width:880px; margin-left: 20px;">

<!-- Start of search options !-->
<a href="javascript:;" onmousedown="toggleDiv('advoptions');"><div id="sidebarheader" style="width:750px; margin-left: auto; margin-right: auto;">Advanced Search<div style="float:right"><img name="optionsimg" src="/nick/bararup.png" alt="minimize"  border="0"/></div></div></a>
<div id="advoptions" class="calitext" style="width: 750px; padding: 5px 5px 5px 5px; border: 1px solid #A0A0A0; border-top: 0px; margin-left: auto; margin-right: auto; display: none;">
    <form name="form1" method="GET" action="database5yr.php">
        <table width="730" border="0" align="center" cellpadding="0" cellspacing="0">
          <tr>
            <td width="240" align="left" valign="top">Show  courses that may allow:<br />
                <input type = "Checkbox" Name ="ch1" value ="a" <? if ($ch1 == 'a') { echo 'checked';} else { echo 'unchecked'; }?> >
                    Resits<br />
                <input type = "Checkbox" Name ="ch2" value ="b" <? if ($ch2 == 'b') { echo 'checked';}?>>
                    Clearing
            </td>
            <td width="240" align="left" valign="top">Show  courses that do not request:<br />
              <input type = "Checkbox" Name ="ch3" value ="c" <? if ($ch3 == 'c') { echo 'checked';}?>>
                    Biology<br />
              <input type = "Checkbox" Name ="ch4" value ="d" <? if ($ch4 == 'd') { echo 'checked';}?>>
                    Chemistry            </td>
            <td width="240" align="left" valign="top">
              Show  courses that do not use the:<br />
              <input type = "Checkbox" Name ="ch5" value ="e" <? if ($ch5 == 'e') { echo 'checked';}?>>
                    UKCAT<br />
              <input type = "Checkbox" Name ="ch6" value ="f" <? if ($ch6 == 'f') { echo 'checked';}?>>
                    BMAT<br />
                    <div style="float: right"><input type = "Submit" name = "Submit1" value = "Find" /></div>
                    <br />
            </td>
          </tr>
        </table>
    </form></div>
<!-- End of search options !-->
<div id="ukmsabout" class="calitext" style="width: 880px; margin-left: auto; margin-right: auto; font-weight: bold; font-size: 14px;">
Click on a medical school name for more information</div>
<div id="sidebarheader" style="width: 880px; text-align:center; line-height: 35px; height: 35px; background-image: url(/nick/sidebarheaderback30.png)">
        <table width="860" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="125"></td>
            <td width="75"><div style="text-align: center">Applications:</div></td>
            <td width="75"><div style="text-align: center">Places:</div></td>
            <td width="75"><div style="text-align: center">Per place:</div></td>
            <td width="75"><div style="text-align: center">Overseas:</div></td>
            <td width="65"><div style="text-align: center">Offer:</div></td>
            <td width="130"><div style="text-align: center">Subjects:</div></td>
            <td width="120"><div style="text-align: center">Tests:</div></td>
            <td width="60"><div style="text-align: center">Resits:</div></td>
            <td width="60"><div style="text-align: center">Clearing:</div></td>
          </tr>
      </table>
    </div>

<? $i=0;
while ($i < $num) {

$Name=mysql_result($result,$i,"Name");
$Applied=mysql_result($result,$i,"Applied");
$Foreign=mysql_result($result,$i,"Foreign");
$APP=mysql_result($result,$i,"APP");
$Accepted=mysql_result($result,$i,"Accepted");
$Biology=mysql_result($result,$i,"Biology");
$Chemistry=mysql_result($result,$i,"Chemistry");
$Grades=mysql_result($result,$i,"Other");
$UKCAT=mysql_result($result,$i,"UKCAT");
$Test=mysql_result($result,$i,"Tests");
$Resits=mysql_result($result,$i,"Resits");
$Clearing=mysql_result($result,$i,"Clearing");
$ID=mysql_result($result,$i,"ID");
?>

<div id="entry<? echo $ID; ?>" class="medschoolbox">
  <table width="860" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td width="125"><div style="font-weight: bold; margin-left: 10px;"><a href="/Forum/schoolstats.php?det=<? echo $ID; ?>"><? echo $Name; ?></a></div></td>
      <td width="75"><div style="text-align: center"><? echo $Applied; ?></div></td>
      <td width="75"><div style="text-align: center"><? echo $Accepted; ?></div></td>
      <td width="75"><div style="text-align: center"><? echo $APP; ?></div></td>
      <td width="75"><div style="text-align: center"><? echo $Foreign; ?></div></td>
      <td width="65"><div style="text-align: center"><? echo $Grades; ?></div></td>
      <td width="65"><div style="text-align: center"><? if ($Biology == '-') {} else {?> <img src="/nick/<? echo $Biology;  ?>b.png" /><? } ?></div></td>
      <td width="65"><div style="text-align: center"><? if ($Chemistry == '-') {} else {?> <img src="/nick/<? echo $Chemistry;  ?>c.png" /><? } ?></div></td>
      <td width="120"><div style="text-align: center">
        <? if ($UKCAT == '-') {} else { echo $UKCAT; } ?>
        <? if ($Test == '-') {} else { echo $Test; }  ?>
      </div></td>
      <td width="60"><div style="text-align: center">
        <? if ($Resits == '-') {} else { echo $Resits; }  ?>
      </div></td>
      <td width="60"><div style="text-align: center">
        <? if ($Clearing == '-') {} else { echo $Clearing; }  ?>
      </div></td>
    </tr>
  </table>
</div>
<? $i++; } ?>
I can't see where I am getting a conflict though
Reply With Quote
  #8  
Old 04-22-2010, 09:31 PM
NickyDee NickyDee is offline
 
Join Date: Aug 2008
Posts: 53
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

* bump *
Reply With Quote
  #9  
Old 04-29-2010, 07:34 PM
NickyDee NickyDee is offline
 
Join Date: Aug 2008
Posts: 53
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

* bump *
Reply With Quote
  #10  
Old 05-01-2010, 11:30 PM
Kyle55155 Kyle55155 is offline
 
Join Date: Mar 2010
Posts: 49
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I followed https://vborg.vbsupport.ru/showthread.php?t=228112 and it worked great. I created a new template called road4 and a new php file called road.php and it works great. Now I need to load up the contents of a php page I built that has lots of php code, db calls, javascript etc. I was thinking this was not going to work until i stumbled across this thread:



I can't seem to figure out exactly what you guys did to get this to work. So at this point I have the custom template based on the global style and I have the php page. So do I need to create another vbulletin PHP page and enter my php-javascript-html code on it? And where do I put

{vb:raw includedphp} ?

and where do I put vB_Template:reRegister('road4',array('includedphp ' => $includedphp));

?

If there are any kind souls who know how to do this I would really appreciate a post back.

NickyDee, I checked out your site and confirmed this is exactly what i need. I;m confused about statsinner.php. In that file you have a bunch of Vbulletin entries in addition to your PHP code.

How did you guys do this? Any help would be greatly appreciated.

Kyle

Kyle
Reply With Quote
Reply


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 06:20 AM.


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.08151 seconds
  • Memory Usage 2,300KB
  • 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
  • (6)bbcode_code
  • (1)bbcode_php
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (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
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete