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

Reply
 
Thread Tools Display Modes
  #11  
Old 05-18-2010, 03:00 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I've seen the link. I have seen no template code posted from you. You cannot use echo statements if you want to put text inside a vbulletin like page.
Reply With Quote
  #12  
Old 05-18-2010, 03:01 PM
borbole's Avatar
borbole borbole is offline
 
Join Date: Jan 2010
Posts: 2,559
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

@danishravian, as adviced above, post here the whole codes that make up your test.php file and your custom template. So we can have a clear and full look.
Reply With Quote
  #13  
Old 05-18-2010, 03:09 PM
danishravian danishravian is offline
 
Join Date: Mar 2010
Posts: 32
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I made a template by name TEST using 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">Title</td>
</tr>
<tr>
    <td class="alt1">Text</td>
</tr>
</table>

$footer
</body>
</html>
Then i made a TEST.php page which contains
PHP Code:
<?php

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

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

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

);

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

// #######################################################################
// ######################## START MAIN SCRIPT ############################
include "connect.php";
$query "select * from plants";
$result mysql_query($query);
$row mysql_fetch_array($result);
 
 
$templater->register('query'$query);
$templater->register('result'$result);
$templater->register('row'$row);

 
if(
mysql_num_rows($result) > 0)
{
     while(
$row mysql_fetch_array($result))
     { 

        echo 
"data found";

    }

}

else

    echo 
"No Record With These Parameters";

}
// #######################################################################

$navbits construct_navbits(array('' => $vbulletin->options['TEST'])); 
$navbar render_navbar_template($navbits); 
// ###### YOUR CUSTOM CODE GOES HERE ##### 
$pagetitle $vbulletin->options['TEST']; 
// ###### NOW YOUR TEMPLATE IS BEING RENDERED ###### 
$templater vB_Template::create('TEST'); 
$templater->register_page_templates(); 
$templater->register('navbar'$navbar); 
$templater->register('pagetitle'$vbulletin->options['TEST']); 
print_output($templater->render()); 

?>
Problem is same that loop is displaying data outside the template as in this link

http://www.haveelskere.dk/test.php
Reply With Quote
  #14  
Old 05-18-2010, 03:22 PM
borbole's Avatar
borbole borbole is offline
 
Join Date: Jan 2010
Posts: 2,559
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by danishravian View Post
I made a template by name TEST using 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">Title</td>
</tr>
<tr>
    <td class="alt1">Text</td>
</tr>
</table>

$footer
</body>
</html>
Then i made a TEST.php page which contains
PHP Code:
<?php

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

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

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

);

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

// #######################################################################
// ######################## START MAIN SCRIPT ############################
include "connect.php";
$query "select * from plants";
$result mysql_query($query);
$row mysql_fetch_array($result);
 
 
$templater->register('query'$query);
$templater->register('result'$result);
$templater->register('row'$row);

 
if(
mysql_num_rows($result) > 0)
{
     while(
$row mysql_fetch_array($result))
     { 

        echo 
"data found";

    }

}

else

    echo 
"No Record With These Parameters";

}
// #######################################################################

$navbits construct_navbits(array('' => $vbulletin->options['TEST'])); 
$navbar render_navbar_template($navbits); 
// ###### YOUR CUSTOM CODE GOES HERE ##### 
$pagetitle $vbulletin->options['TEST']; 
// ###### NOW YOUR TEMPLATE IS BEING RENDERED ###### 
$templater vB_Template::create('TEST'); 
$templater->register_page_templates(); 
$templater->register('navbar'$navbar); 
$templater->register('pagetitle'$vbulletin->options['TEST']); 
print_output($templater->render()); 

?>
Problem is same that loop is displaying data outside the template as in this link

http://www.haveelskere.dk/test.php


Your template is all wrong. Try to create a correct one for vb 4x by using the example at this tutorial.

https://vborg.vbsupport.ru/showthread.php?t=228112
Reply With Quote
  #15  
Old 05-18-2010, 04:05 PM
danishravian danishravian is offline
 
Join Date: Mar 2010
Posts: 32
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I did all (updated my work), but still same problem

http://www.haveelskere.dk/test.php
Reply With Quote
  #16  
Old 05-18-2010, 04:41 PM
cellarius's Avatar
cellarius cellarius is offline
 
Join Date: Aug 2005
Posts: 1,987
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You need to take the time and try to understand what happens in the code.

1. You can not use echo, as Lynne already told you. That's what makes the results show up on top of the pages. You need to save the output of the loop into a variable, and that variable needs to be registered for use in your template. Replace echo with
PHP Code:
$output 
// or, since we're in a loop,
$output .= 
2. Get your php code in order. There is a good cause for the comment "Your custom code goes here". Why don't you put your custom code there, but somewhere above? That's all messy!

3. There's no sense in wildly registering variables like $query, $row and $result in the middle of nowhere. Those three variables are only used in your php code, so there is no need to register them. Registering variables is for passing variables from the php code to the template. This happens under the comment "Now your template is being rendered." Add a line like this

PHP Code:
$templater->register('output'$output); 
where some other variables are being registered already and call it in the template using
HTML Code:
{vb:raw output}
Reply With Quote
  #17  
Old 05-19-2010, 12:46 PM
danishravian danishravian is offline
 
Join Date: Mar 2010
Posts: 32
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

PHP Code:
<?php

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

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

define('THIS_SCRIPT''test');
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('TEST',
);

// 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 ('/path/to/your/forums');
require_once('./global.php');

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

$navbits construct_navbits(array('' => 'Test Page'));
$navbar render_navbar_template($navbits);
$code "<div style='font-family: Arial, Helvetica, sans-serif;
    font-size: 15px;
    font-weight: bold;
    padding-left:30px;' >Sun flower</div>
<div style='width:106px;
height:109px;
margin-left:20px;
float:left;'><img src='images/flower_03.png' style='float:left' /></div>
<div style='height:150px;
width:338px;
float:left;'><div style='font-family: Arial, Helvetica, sans-serif;
    font-size: 13px;
    line-height: 19px;
    font-weight: normal;
    padding-left:6px;'>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque vulputate, nibh eget ehiculaolestie, augue mi eleifend eros, fermentuaculis agna diam sed mi. Fusce euismodtortor at Fusce euismodtortor at</div> </div>
<div><div style='height:150px;
width:109px;
float:left;'><img src='images/Untitled-1.png' /><br />PlantsBlooms<br />Size<br />Light</div></div>
<div style='float:left;'>
4.5/5<br />
May - June<br />
May - June<br />
May - June<br /></div>
</div>



<div style='width:687;
height:142px;
padding-top:13px;
border:ridge;
border-width:2px;
border-color:cddee9;
margin-top:10px;'>"
;

include 
"connect.php";
$result  $db->query_read("SELECT * from plants");
$resultset $db->fetch_array($result);

while (
$userdata $db->fetch_array($result))
{
// nun stehen die Daten in $userdata zur Verf?gung
echo $userdata['id'];
}

// ###### YOUR CUSTOM CODE GOES HERE #####
$pagetitle 'My Page Title';

// ###### NOW YOUR TEMPLATE IS BEING RENDERED ######

$templater vB_Template::create('TEST');
$templater->register_page_templates();
$templater->register('navbar'$navbar);
$templater->register('pagetitle'$pagetitle);
$templater->register('code'$code);
print_output($templater->render());

?>

i have registered my variable $code in template and its working OK.
if i use this code to display data, it displays it outside the template
but i have to display all records from database.
how it can be done?? any clue

PHP Code:
$result  vB::$vbulletin->db->query_read("SELECT * from plants");
$resultset vB::$vbulletin->db->fetch_array($result);

while (
$userdata vB::$vbulletin->db->fetch_array($result))
{
// nun stehen die Daten in $userdata zur Verf?gung
echo $userdata['id'];

First I was using this code to get and dislpay data. But it was dislplaying error message that "VB class not found"

--------------- Added [DATE]1274277151[/DATE] at [TIME]1274277151[/TIME] ---------------

cellarius thnxxxxx a lottttttt a got some Idea
you are sooo goood
Reply With Quote
  #18  
Old 05-19-2010, 02:04 PM
cellarius's Avatar
cellarius cellarius is offline
 
Join Date: Aug 2005
Posts: 1,987
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

For everyone else interested: The problem most likely was that there still was an echo statement in the php code.

Glad you figured it out
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 09:33 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04275 seconds
  • Memory Usage 2,304KB
  • Queries Executed 13 (?)
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
  • (3)bbcode_html
  • (6)bbcode_php
  • (1)bbcode_quote
  • (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
  • (8)post_thanks_box
  • (8)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (8)post_thanks_postbit_info
  • (8)postbit
  • (8)postbit_onlinestatus
  • (8)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_postinfo_query
  • fetch_postinfo
  • 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