View Single Post
  #176  
Old 07-23-2011, 04:36 PM
Dave-ahfb Dave-ahfb is offline
 
Join Date: Mar 2002
Posts: 117
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

First let me say that I am not PHP literate, but can find my way around 9 times out of 10.

I am creating custom templates to include my non vb scripts but am having troubles when trying to include a variable(?) from this script in any template outside the main body.

I will try to be as detailed as possible, hopefully any responses will include the information I give as a real life example so that I can get an understanding of what was done.


Goal: to take $companyname from the below script and add it to my page title, navbits etc. (currently I only get echos of $companyname or {vb:raw companyname}, depending on where I am in my efforts.
PHP Code:
if (isset($_GET['company']))
    
$company $_GET['company'];
   else
    
$company '100megs';
$result mysql_query("select * from hostwebhost where companyname = '$company'");
if (!
$result) {
$numrows 0;
} else {
$numrows mysql_num_rows($result);
}
for(
$x=0;$x<$numrows;$x++){
while (
$row mysql_fetch_array($result)){
$host_id $row[0];
$companyname $row[1];
$emailaddress $row[2]; 
$URL $row[3]; 
$track $row[4]; 
$imgtop $row[5]; 
$imgright $row[6]; 
$imgbody $row[7]; 
$joined $row[8]; 
$password $row[9]; 
$isvalid $row[10]; 
$supportlist $row[11]; 
$street1 $row[12]; 
$street2 $row[13]; 
$city $row[14]; 
$state $row[15]; 
$zip $row[16]; 
$country $row[17]; 
$contactname $row[18]; 
$contactphone $row[19]; 
$contactfax $row[20]; 
$suggested $row[21]; 
$comdescrip $row[22]; 
$registered $row[23]; 
plugin info:
PHP Code:
locationglobal_bootstrap_init_start
title
Webhost-php Include
execution order5
code
:
ob_start();
ob_start();
include(
'/srv/www/findnewhosting.com/public_html/webhost1.php');
$webhost ob_get_contents();
ob_end_clean(); 
vB_Template::preRegister('webhost-php', array('webhost' => $webhost)); 
As you can see the script is webhost1.phpwhich includes the first set of code above. Please note that the custom page is webhost.php which contains the following:
PHP Code:
<?php

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

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

define('THIS_SCRIPT''webhosting');
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('webhost-php',);

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

// ######################### REQUIRE BACK-END ############################
chdir ('/srv/www/findnewhosting.com/public_html');

require_once(
'/srv/www/findnewhosting.com/public_html/global.php');

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

$navbits construct_navbits(array('' => '&nbsp;</span></li><li class="navbit"><span><a href="/">Home</a></span></li><li class="navbit"><span><a href="../hostindex.php">Web Hosting</a></span></li><li class="navbit lastnavbit"><span>{vb:raw companyname} 

'
));
$navbar render_navbar_template($navbits);

// ###### YOUR CUSTOM CODE GOES HERE #####
$pagetitle '$companyname';
$templater vB_Template::create('headerincludea');
$headerincludea $templater->render();
$templater vB_Template::create('webhost-php');
$templater->register_page_templates();
$templater->register('navbar'$navbar);
$templater->register('pagetitle'$pagetitle);
$templater->register('sidebarext'$sidebarext);
$templater->register('sidebaropen'$sidebaropen);
$templater->register('headerincludea'$headerincludea);


print_output($templater->render());
?>
webhost-php(template):
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 companyname}</title>
{
vb:raw headerincludea}
{
vb:raw headinclude_bottom}
</
head>
<
body>
{
vb:raw header}
{
vb:raw navbar}
{
vb:raw sidebaropen}
<
br />
<
div id="pagetitle">
<
h1>&nbsp;&nbsp;{vb:raw pagetitle}</h1><br />
</
div>
<
div class="blockbody">
<
div class="blockrow">
<
div align="center">

{
vb:raw webhost}

</
div>
</
div>
</
div>
    {
vb:raw sidebarext}


    {
vb:raw footer}
  </
body>
</
html
If there is any other info I can give to make it easier to solve just let me know.

Dave
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01423 seconds
  • Memory Usage 1,853KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (4)bbcode_php
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.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_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • 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
  • showpost_complete