vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 4 Articles (https://vborg.vbsupport.ru/forumdisplay.php?f=242)
-   -   [HOW TO - vB4] Rendering templates and registering variables - a short guide (https://vborg.vbsupport.ru/showthread.php?t=228078)

BirdOPrey5 12-26-2012 04:51 PM

What error are you getting?

acast 12-26-2012 05:12 PM

Quote:

Originally Posted by BirdOPrey5 (Post 2392843)
What error are you getting?

I don't know what exactly is the problem, in this case, is like the things aren't well connected. When i put hangman.php in 3.6, automatically add to the direction "?n=1" and if i clikc in the letters the program run well, but in 4 didn't do it. Also, in other plugin i have a button, but if i click it doesn't go to anywhere.

My question is: if you register a variable that doesn't have to be register, the php makes an error? I did this in the plugin:
Code:

$templater = vB_Template::create('hangman');
$templater->register_page_templates();
$templater->register('hangmanwords', $hangmanwords);
$templater->register('hangmanmax', $hangmanmax);
$templater->register('hangmanguests', $hangmanguests);
$templater->register('letters', $letters);
$templater->register('n', $n);
$templater->register('additional_letters', $additional_letters);
$templater->register('words', $words);
$templater->register('alpha', $alpha);
$templater->register('all_letters', $all_letters);
$templater->register('wrong', $wrong);
$templater->register('word', $word);
$templater->register('done', $done);
$templater->register('word_line', $word_line);
$templater->register('c', $c);
$templater->register('links', $links);
$templater->register('max', $max);
$templater->register('x', $x);
$templater->register('sorry', $sorry);
$templater->register('play', $play);
$templater->register('win', $win);
$templater->register('term', $term);
$templater->register('guess', $guess);
$templater->register('nwrong', $nwrong);
$templater->register('navbar', $navbar);
$templater->register('pagetitle', $pagetitle);
print_output($templater->render());

but i don't know if all these variables must to be put it like this.

Sorry for my english, and thanks for your help. Also, the plugin, if you want to see it something more of the code is here:
https://vborg.vbsupport.ru/showthrea...hlight=hangman

Lynne 12-26-2012 05:25 PM

Can you post your hangman template code?

acast 12-26-2012 05:34 PM

Quote:

Originally Posted by Lynne (Post 2392848)
Can you post your hangman template code?

Hi Lynne :)

The original template hangman:
Code:

$stylevar[htmldoctype]
<html dir="$stylevar[textdirection]" lang="$stylevar[languagecode]">
<html>
<head>
<meta name="description" content="$foruminfo[description]" />
<title>$vboptions[bbtitle] - $vbphrase[vb_hangman]</title>
$headinclude
</head>
<body>
$header
$navbar
<br>
<table class="tborder" cellpadding="0" cellspacing="0" border="0" bgcolor="0" width="100%" align="center"><tr><td>
<table cellpadding="$stylevar[cellpadding]" cellspacing="0" border="0" width="100%">
<tr id="cat">
        <td bgcolor="{categorybackcolor}" colspan="5" class="tcat"><b> $vbphrase[vb_hangman]</b>
</td>
</tr>
<table cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" border="0" width="100%">

          <td class="alt1">
<br>
</div>
            <center>
<p>
<img src="images/hangman/hangman_$nwrong.gif" align="absmiddle" border="0" height="100" width="100" alt="Wrong: $wrong out of $max">
</p>
$sorry $play $guess $win
<br><br><br>
            </center>
</tr>
</td>
<tr>
        <td class="tfoot">
&nbsp;
</td>
</tr>
</table>
</table>
</td></tr></table>
$footer
</body>
</html>

My modified template:
Code:

{vb:stylevar htmldoctype}
<html dir="{vb:stylevar textdirection}" lang="{vb:stylevar languagecode} id="vbulletin_html">
<html>
<head>

<title>{vb:raw vboptions.bbtitle} - {vb:raw pagetitle}</title>
{vb:raw headinclude}
</head>
<body>
{vb:raw header}
{vb:raw navbar}
<br>
<table class="tborder" cellpadding="0" cellspacing="0" border="0" bgcolor="0" width="100%" align="center"><tr><td>
<table cellpadding="{vb:stylevar cellpadding}" cellspacing="0" border="0" width="100%">
<tr id="cat">
        <td bgcolor="{categorybackcolor}" colspan="5" class="tcat"><b> {vb:raw phrase vb_hangman}</b>
</td>
</tr>
<table cellpadding="{vb:stylevar cellpadding}" cellspacing="{vb:stylevar cellspacing}" border="0" width="100%">

          <td class="alt1">
<br>
</div>
            <center>
<p>
<img src="images/hangman/hangman_{vb:raw nwrong}.gif" align="absmiddle" border="0" height="100" width="100" alt="Wrong: {vb:raw wrong} out of {vb:raw max}">
</p>
{vb:raw sorry} {vb:raw play} {vb:raw guess} {vb:raw win}
<br><br><br>
            </center>
</tr>
</td>
<tr>
        <td class="tfoot">
&nbsp;
</td>
</tr>
</table>
</table>
</td></tr></table>
{vb:raw footer}
</body>
</html>

Thanks for your help too. This plugin is not important for me, but i want to learn so i can do it in other ones more important :)

Lynne 12-27-2012 12:04 AM

The template looks OK.... I don't see a link to the page so we can see exactly what is happening. Something can "not work" in so many different ways, so it would be good to see exactly what is going on with this one.

acast 12-27-2012 07:16 AM

1 Attachment(s)
Quote:

Originally Posted by Lynne (Post 2392912)
The template looks OK.... I don't see a link to the page so we can see exactly what is happening. Something can "not work" in so many different ways, so it would be good to see exactly what is going on with this one.

Ok, i'll send you now a private message with the login to my forum. If somebody wants it too, tell me.


This is another plugin where i have, apparently, the same problem:
The code is in the attached txt.


Thank you for your help again. I reall apreciate always your help Lynne.

BirdOPrey5 12-27-2012 03:28 PM

Registering a variable that doesn't need to be registered or is empty will NOT cause an error.

Are you just getting a blank white page when you try to view it? In that case look for your php error log (your host may be able to tell you how to view it) and see what errors are coming up after trying to view the blank page.

acast 12-27-2012 03:38 PM

Quote:

Originally Posted by BirdOPrey5 (Post 2393057)
Registering a variable that doesn't need to be registered or is empty will NOT cause an error.

Are you just getting a blank white page when you try to view it? In that case look for your php error log (your host may be able to tell you how to view it) and see what errors are coming up after trying to view the blank page.

Thank you for the answer. I sent you also the links for if you want to take a look.

Also i have another question of the use in the templates. For example, in the code that i put, in the old one appears like this:
Code:

<vb:if condition="$stocktable != null">
That is right for the templates?

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

I solve the problem of the hangman. It seems like the PHP_SELF doesn't work in v4. Thanks to Lynne for the help.

But i am working in the other one. My previous question to BirdOprey5 is about it.

Lynne suspect that perhaps the problem is about javascript/ajax. ?Is different to v3 to v4?

This is the code, if somebody knows that it is right or wrong:

Code:

//-----------------------------------------------------------------------------
// $Workfile: vbulletin_ajax_stocktrader.js $ $Revision: 1.4 $ $Author: addy $
// $Date: 2007/01/02 03:31:59 $
//-----------------------------------------------------------------------------

var stock_xml;

function handle_stock_lookup(symbol)
{
        stock_xml = new vB_AJAX_Handler(true);
        stock_xml.onreadystatechange(handle_stock_lookup_response);
        stock_xml.send('vbtrade.php?do=lookup&symbol=' + symbol);
       
        return false;
}

function handle_stock_lookup_response()
{
        if (stock_xml.handler.readyState == 4 && stock_xml.handler.status == 200)
        {
                if (stock_xml.handler.responseXML)
                {
                        var response = stock_xml.fetch_data(fetch_tags(stock_xml.handler.responseXML, 'tag1')[0]);
                        if (response != null)
                        {       
                                var lookup_table = null;
                               
                                if (document.getElementById)
                                        lookup_table = document.getElementById('lookup_table');

                                if (lookup_table)
                                        lookup_table.innerHTML = response;
                        }
                }
        }
}

Thanks if anybody can take a look to it and verify that it is right.

BirdOPrey5 12-29-2012 07:43 PM

Code:

<vb:if condition="$stocktable != null">
That looks allowed in VB4 template, of course it need an ending </vb:if> somewhere.

I'm sorry I don't know anything about AJAX differences between VB3 and VB4.

acast 12-30-2012 08:22 AM

Quote:

Originally Posted by BirdOPrey5 (Post 2393443)
Code:

<vb:if condition="$stocktable != null">
That looks allowed in VB4 template, of course it need an ending </vb:if> somewhere.

I'm sorry I don't know anything about AJAX differences between VB3 and VB4.

Thanks, it doesn't seem to be anything about ajax. I put it the problem here:
https://vborg.vbsupport.ru/showthrea...=242454&page=7

That variable "stocktable" must be registered in a plugin, but if i do it the forum dissapears.


All times are GMT. The time now is 01:17 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.01813 seconds
  • Memory Usage 1,764KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (7)bbcode_code_printable
  • (5)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (1)pagenav_pagelinkrel
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete