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)

Craigr 07-20-2012 02:07 PM

I am creating a custom mod for my site, at the moment i have done this and only get a white page displayed, but at least the result appears. I am not sure what example to follow so that the rest of the showthread template appears too?

Plugin:
Product: vBulletin
Hook Location: showthread_post_start
Title: galleryimagedisplay
Execution Order: 5
PHP Code:
Code:

$result = $db->query_first("SELECT * FROM dbtech_gallery_images WHERE roll_id = '$threadid'");
$id = $result[imageid];
$title = $result[title];

$templater = vB_Template::create('test');
$templater->register('id', $id);
$templater->register('title', $title);
$templatevalues['my_insertvar'] = $templater->render();
vB_Template::preRegister('SHOWTHREAD', $templatevalues);

This is my template:
Code:

{vb:raw id} {vb:raw title}
Edit: Got the above displaying ok now.

BirdOPrey5 07-20-2012 02:46 PM

off hand it's vb:raw in the templates, not vbraw: and there is no $ either.

Code:

Test Text: {vb:raw id} {vb:raw title}

Steve St.Lauren 08-04-2012 12:06 AM

I'm trying to use several of my user custom fields on a page in profile.php. I've got the template working and the page is displaying ok but I can't get the custom fields to display. I've tried a ton of stuff and just can't get it to work - would GREATLY appreciate any help you could provide. Here's what I'm doing now. This is the plug in code going into profile.php:

if ($_REQUEST['do'] == 'showsubscription')
{
echo 'test';
$customfields = array();
fetch_profilefields(0);
$page_templater = vB_Template::create('showsubscription');
$page_templater->register('customfields', $customfields);
}

in the template itself I'm putting in:

{vb:raw customfields.value11}

where I want to use the field. I've also tried customfields.field11 various permutation of userinfo, userfield, etc. I was able to do this in vb3 no problem but having a tough time getting it to work in vB4.

BirdOPrey5 08-04-2012 08:36 AM

Do you have the working 3.x code?

Steve St.Lauren 08-04-2012 08:59 PM

Yes, in VB3 it was very easy - all I had to do was put $bbuserinfo[field11] on the template. The plugin portion of it was:

// ############################ start show subscription info ##########################
if ($_REQUEST['do'] == 'showsubscription')
{
construct_usercp_nav('showsubscription');

$navbits[''] = 'Subscription Status';
$templatename = 'showsubscription';
$url =& $vbulletin->url;
}

BirdOPrey5 08-05-2012 10:34 AM

I'm sorry, either I don't understand what you are trying to do or are missing something big.

Steve St.Lauren 08-05-2012 06:24 PM

I have a number of custom user fields created and I want for the values of those fields to appear on a profile page. In this case it's a subscription status page that lets the user know when their subscription expires and how many issues they have left remaining on their subscription. In VB3 the profile.php page had $bbuserinfo loaded with those fields and they could be called simply by putting $bbuserinfo[field11] in the template - it would put the value there.

showsubscription was the name of the custom template that I created and it would appear along with all of the profile page navigation around it. I have the showsubscription template appearing in vb4 now but I can't get the values of the custom fields to appear on the page. I'm pretty sure it will involve the {vb raw} function and registering a variable for it to be able to appear in the template but just can't figure it out. profile.php must already be loading the custom user fields somewhere because it's used elsewhere on the page.

PyroChixRock 08-12-2012 10:39 PM

I have this little random banner code I've always used through the plugin system, but I can't seem to get it to work on vb4. Can anyone help?

normally, I call for it below the navbar with this...
Code:

<br>
<div style="text-align: center;">
$randombanner
</div>

and this for example, in the plugin area.
Code:

$path = '/forum/images/adbanners/';
$banners = array(
array( 'src' => 'imagine.jpg',
'href' => 'http://www.talkglass.com/'),
array( 'src' => 'waiting.jpg',
'href' => 'http://www.talkglass.com/),
);


$rnd = rand(0,count($banners)-1); // Pick a random array index.  They start with 0, so you have to -1.
$href = $banners[$rnd]['href'];  // Link HREF
$src = $path.$banners[$rnd]['src']; // Image source
$randombanner = '<a href="'.$href.'"><img border="0" src="'.$src.'" /></a>';

Where should i plug these in now for them to work with the built in ad system. it doesn't work using that.

kh99 08-13-2012 12:13 PM

Quote:

Originally Posted by PyroChixRock (Post 2356515)
Where should i plug these in now for them to work with the built in ad system. it doesn't work using that.


Try using hook parse_templates and at the end of your plugin code add:
Code:

vB_Template::preRegister('navbar', array('randombanner' => $randombanner));

Then in the navbar template, use this:
Code:

<br>
<div style="text-align: center;">
{vb:raw randombanner}
</div>


PyroChixRock 08-13-2012 05:59 PM

Thanks, Kevin. I really appreciate you taking the time to reply.

It seems I have everything right but it's not showing up.

I'm not sure what else to do but this is the last thing I need before I can go live with my upgrades. VB is no help because it's custom code.

I'm not sure what else to tell you that would be helpful? Would you be willing to hop over to my test forum and have a look? If so send me a pm and I'll give you login info.

kh99 08-13-2012 11:21 PM

It could be because I had the code wrong - I fixed it in my post above. :o

PyroChixRock 08-13-2012 11:57 PM

Yay! that was it. I can't thank you enough. :D

Jonathan81 08-29-2012 01:06 PM

Quote:

Originally Posted by PyroChixRock (Post 2356515)
I have this little random banner code I've always used through the plugin system, but I can't seem to get it to work on vb4. Can anyone help?

normally, I call for it below the navbar with this...
Code:

<br>
<div style="text-align: center;">
$randombanner
</div>

and this for example, in the plugin area.
Code:

$path = '/forum/images/adbanners/';
$banners = array(
array( 'src' => 'imagine.jpg',
'href' => 'http://www.talkglass.com/'),
array( 'src' => 'waiting.jpg',
'href' => 'http://www.talkglass.com/),
);


$rnd = rand(0,count($banners)-1); // Pick a random array index.  They start with 0, so you have to -1.
$href = $banners[$rnd]['href'];  // Link HREF
$src = $path.$banners[$rnd]['src']; // Image source
$randombanner = '<a href="'.$href.'"><img border="0" src="'.$src.'" /></a>';

Where should i plug these in now for them to work with the built in ad system. it doesn't work using that.

Do you know how I can make the links open in a new window using the above code?

cellarius 08-29-2012 01:14 PM

It has nothing at all to do with the topic of this article, but:

Last line:
$randombanner = '<a href="'.$href.'" target="_blank"><img border="0" src="'.$src.'" /></a>';

Jonathan81 08-29-2012 01:22 PM

Quote:

Originally Posted by cellarius (Post 2360947)
It has nothing at all to do with the topic of this article, but:

Last line:
$randombanner = '<a href="'.$href.'" target="_blank"><img border="0" src="'.$src.'" /></a>';

Yes, I know, apologies...and thank you :)

soulz2003 10-16-2012 11:15 AM

The thing I am not understanding at this point is. If I am trying to preregister a variable for use with a stock template, in this case header. Where am I putting my code?

Is there a stock location to add this to or am I having to jump from adding a simple variable used on sites since vb 3.x into learning the basics of plugin writing? GLOBALS.permissions.pmquota isn't working for me in a new situation so I am trying to learn how to register permissions with the header template.

I believe the code is going to look like this?
Code:

$permissions = $vbulletin->userinfo['permissions'];
vB_Template::preRegister('header',array('permissions' => $permissions));

If so or even once correct where is this going? I mean were talking about a stock item for a stock template not a 3rd party plugin so I am confused.

Also is the above enough or do I need to add more like:
Code:

$permissions['pmquota'] = vb_number_format($vbulletin->userinfo['permissions']['pmquota']);

kh99 10-16-2012 08:03 PM

I answered in your other thread, but I'll answer more generally here: for the header, navbar, and footer templates I would recommend the hook parse_templates, since that's always executed just before those templates are rendered.

But the variable you want to use has to be available at that hook, and the timing of the call to the parse_templates hook can change. In the case of $permissions, that is set just after the global_start hook is called, so if some plugin using the global_start hook renders a template, parse_templates will be called but $permissions won't have been set yet so preRegistering it to a template won't work. (That's also why GLOBALS.permissions.pmquota stopped working - using preRegister() instead won't make any difference). But as I mentioned in the other thread, $permission is just a copy of $vbulletin->userinfo['permissions'], so if you use {vb:raw bbuserinfo.permissions.pmquota} in the template, that may work without any preRegistering.

TheSupportForum 10-17-2012 02:17 AM

is this possible

PHP Code:

$array = array($vbulletin->options['list1']); or array($vbulletin->options['list2']); 

i need to be able to use and array for 2 or more options, how can this be done

BirdOPrey5 10-21-2012 09:22 PM

As you wrote it, it is not going to work, you can't just put an "or" in the middle of any code.

I'm not really sure what your goal is or I'd give you an idea where to go... Maybe..

PHP Code:

$array = array(); //New array
$array[0] = $vbulletin->options['list1'];
if (
$vbulletin->options['list2']) // If list2 exists
  
$array[] = $vbulletin->options['list2']; 

That creates new array...

Assuming list1 always exists array[0] gets its value

Then If list2 exists the next element in array (array[1] in this case) gets the value of list2

acast 12-26-2012 12:57 PM

Hi, i am trying to learn how to adjust the plugins for v3 to v4.

Can anybody guide me and tell me what it's wrong?

Code working in 3.6.6.

Code:

<?php

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

// #################### DEFINE IMPORTANT CONSTANTS #######################
define('THIS_SCRIPT', 'hangman');
$globaltemplates = array(
        'hangman'
);
// pre-cache templates used by specific actions
$actiontemplates = array();


//vB Hangman 2.0 by Dr. Erwin Loh (Admin at vBulletin.org)
//Enjoy this hack!

require_once('./global.php');


$hangmanwords=&$vbulletin->options['hangmanwords'];
$hangmanmax=&$vbulletin->options['hangmanmax'];
$hangmanguests=&$vbulletin->options['hangmanguests'];



if ($hangmanguests==0) {
if (!$vbulletin->userinfo['userid']) {
print_no_permission();
 }
}
$vbulletin->input->clean_array_gpc('r', array(
        'letters' => TYPE_STR,
        'n' => TYPE_UINT
));
$letters = &$vbulletin->GPC['letters'];
$n = &$vbulletin->GPC['n'];
$additional_letters = " -.,;!?%&0123456789";       
$max=$hangmanmax;                                       
$hangmanwords = strtoupper($hangmanwords);
$words = explode(",",$hangmanwords);
$alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
$all_letters=$letters.$additional_letters;
$wrong = 0;
srand((double)microtime()*1000000);
if (!isset($n)) {
$n = rand(1,count($words)-1);
}
$word_line="";
$word = $words[$n];
$done = 1;
for ($x=0; $x < strlen($word); $x++)
{
  if (strstr($all_letters, $word[$x]))
  {
    if ($word[$x]==" ") $word_line.="&nbsp; "; else $word_line.=$word[$x];
  }
  else
{
$word_line.="_<font size=1>&nbsp;</font>"; $done = 0; }
}
if (!$done)
{
  for ($c=0; $c<26; $c++)
  {
    if (strstr($letters, $alpha[$c]))
    {
      if (strstr($words[$n], $alpha[$c])) {
$links .= "\n<B>$alpha[$c]</B> ";
}
      else
{
$links .= "\n<FONT color=\"red\">$alpha[$c] </font>"; $wrong++;
}
    }
    else
    {
$links .= "\n<A HREF=\"$PHP_SELF?letters=$alpha[$c]$letters&n=$n\">$alpha[$c]</A> "; }
  }
  $nwrong=$wrong;
  if ($wrong >= $max)
  {
$n = rand (1,count($words)-1);
    if ($n>(count($words)-1)) $n=0;
    $sorry .= "<BR><BR><H1><font size=5>\n$word_line</font></H1>\n<p><BR><FONT color=\"red\"><BIG>SORRY, YOU ARE HANGED!!!</BIG></FONT><BR><BR>";
    if (strstr($word, " ")) $term="phrase"; else $term="word";
    $play .= "The $term was \"<B>$word</B>\"<BR><BR>\n<A HREF=$PHP_SELF?n=$n>Play again.</A>\n\n";
  }
  else
  {
    $guess .= " &nbsp; Number of Wrong Guesses Left: <B>".($max-$wrong)."</B><BR>\n<H1><font size=5>\n$word_line</font></H1>\n<P><BR>Choose a letter:<BR><BR>\n$links\n";
  }
}
else
{
$n = rand (1,count($words)-1);
  if ($n>(count($words)-1)) $n=0;
  $win .= "<BR><BR><H1><font size=5>\n$word_line</font></H1>\n<P><BR><BR><B>Congratulations $bbuserinfo[username]!!! &nbsp;You have won!!!</B><BR><BR><BR>\n<A HREF=$PHP_SELF?n=$n>Play again</A>\n\n";
}
  $navbits = construct_navbits(array('' => $vbphrase['vb_hangman']));
eval('$navbar = "' . fetch_template('navbar') . '";');
eval('print_output("' . fetch_template(hangman) . '");');
?>

My modified code:
Code:

<?php

// ####################### SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);
ini_set("display_errors", 1);
// #################### DEFINE IMPORTANT CONSTANTS #######################
define('THIS_SCRIPT', 'hangman');
// ################### PRE-CACHE TEMPLATES AND DATA ######################
// get special phrase groups
$phrasegroups = array();
// get special data templates from the datastore
$specialtemplates = array();
$globaltemplates = array(
        'hangman'
);
// pre-cache templates used by specific actions
$actiontemplates = array();


//vB Hangman 2.0 by Dr. Erwin Loh (Admin at vBulletin.org)
//Enjoy this hack!

require_once('./global.php');


$hangmanwords=&$vbulletin->options['hangmanwords'];
$hangmanmax=&$vbulletin->options['hangmanmax'];
$hangmanguests=&$vbulletin->options['hangmanguests'];



if ($hangmanguests==0) {
if (!$vbulletin->userinfo['userid']) {
print_no_permission();
 }
}
$vbulletin->input->clean_array_gpc('r', array(
        'letters' => TYPE_STR,
        'n' => TYPE_UINT
));
$letters = &$vbulletin->GPC['letters'];
$n = &$vbulletin->GPC['n'];
$additional_letters = " -.,;!?%&0123456789";       
$max=$hangmanmax;                                       
$hangmanwords = strtoupper($hangmanwords);
$words = explode(",",$hangmanwords);
$alpha = "ABCDEFGHIJKLMN?OPQRSTUVWXYZ";
$all_letters=$letters.$additional_letters;
$wrong = 0;
srand((double)microtime()*1000000);
if (!isset($n)) {
$n = rand(1,count($words)-1);
}
$word_line="";
$word = $words[$n];
$done = 1;
for ($x=0; $x < strlen($word); $x++)
{
  if (strstr($all_letters, $word[$x]))
  {
    if ($word[$x]==" ") $word_line.="&nbsp; "; else $word_line.=$word[$x];
  }
  else
{
$word_line.="_<font size=1>&nbsp;</font>"; $done = 0; }
}
if (!$done)
{
  for ($c=0; $c<26; $c++)
  {
    if (strstr($letters, $alpha[$c]))
    {
      if (strstr($words[$n], $alpha[$c])) {
$links .= "\n<B>$alpha[$c]</B> ";
}
      else
{
$links .= "\n<FONT color=\"red\">$alpha[$c] </font>"; $wrong++;
}
    }
    else
    {
$links .= "\n<A HREF=\"$PHP_SELF?letters=$alpha[$c]$letters&n=$n\">$alpha[$c]</A> "; }
  }
  $nwrong=$wrong;
  if ($wrong >= $max)
  {
$n = rand (1,count($words)-1);
    if ($n>(count($words)-1)) $n=0;
    $sorry .= "<BR><BR><H1><font size=5>\n$word_line</font></H1>\n<p><BR><FONT color=\"red\"><BIG>SORRY, YOU ARE HANGED!!!</BIG></FONT><BR><BR>";
    if (strstr($word, " ")) $term="phrase"; else $term="word";
    $play .= "The $term was \"<B>$word</B>\"<BR><BR>\n<A HREF=$PHP_SELF?n=$n>Play again.</A>\n\n";
  }
  else
  {
    $guess .= " &nbsp; Number of Wrong Guesses Left: <B>".($max-$wrong)."</B><BR>\n<H1><font size=5>\n$word_line</font></H1>\n<P><BR>Choose a letter:<BR><BR>\n$links\n";
  }
}
else
{
$n = rand (1,count($words)-1);
  if ($n>(count($words)-1)) $n=0;
  $win .= "<BR><BR><H1><font size=5>\n$word_line</font></H1>\n<P><BR><BR><B>Congratulations $bbuserinfo[username]!!! &nbsp;You have won!!!</B><BR><BR><BR>\n<A HREF=$PHP_SELF?n=$n>Play again</A>\n\n";
}
$navbits = construct_navbits(array('' => $vbphrase['vb_hangman']));
$navbar = render_navbar_template($navbits);
// ###### YOUR CUSTOM CODE GOES HERE #####
$pagetitle = 'hangman';
// ###### NOW YOUR TEMPLATE IS BEING RENDERED ######
$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());
?>

It doesn't work, and i don't know why. I tried with several plugins but no one works. Thanks for your help.

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.

ezak 04-09-2013 06:07 PM

Links and Download Modification is stoped supported because the author is died

I have problem in vb 4.2.0 can't register the variables

1- plugins
Name: Links and Downloads Manager - Add LDM to main vBulletin menu
Hooks: Prosses_templates_complete
code:
PHP Code:

    require_once(DIR '/includes/local_links_defns.php');

    if (
LDM_NAVBAR_LOCATION) {

        if (
defined('THIS_SCRIPT') and
                (
               
THIS_SCRIPT == LDM_LINKS_SCRIPT    or THIS_SCRIPT == 'local_links'
            
or THIS_SCRIPT == LDM_ACTION_SCRIPT    or THIS_SCRIPT == 'local_links_actions'
            
or THIS_SCRIPT == LDM_ADMIN_SCRIPT    or THIS_SCRIPT == 'local_links_admin'
            
or THIS_SCRIPT == LDM_SEARCH_SCRIPT    or THIS_SCRIPT == 'local_links_search'
                
)
            ) {
// Highlight ldm tab when in LDM - LDM code will create the actual tab and navbar
            
$vbulletin->options['selectednavtab'] = 'ldm';
        }
        else {
// Create the tab, no navbar needed
            
$templater vB_Template::create('links_navbar');
            
$templater->quickRegister(array(
                
'ldm_links_script'=>LDM_LINKS_SCRIPT,
                ));
            
$template_hook[LDM_NAVBAR_LOCATION] .= $templater->render();
        }

    } 


2- /includes/local_links_defns.php
PHP Code:

<?php

/* ===========================================================================*/
//
// This code is provided free on the basis that you do not claim that
// it is your own, sell it or use it as the basis for other products that you
// sell. But by all means extend it, modify it, upgrade it, correct it,
// suggest improvements, call me an idiot, etc.
//
// (c) 2004/10
// Andrew Dearing
// European Industrial Research Management Association
// www.eirma.org
//
// v3.0.2, 05.02.2010
// For VB4.0.x
// see changes.txt for history
// v1.00, 1.3.2004
//
/* ===========================================================================*/

// These definitions should correspond to the names of the main LDM scripts
// (held in the forums directory

define('LDM_LINKS_SCRIPT',        'local_links');
define('LDM_ACTION_SCRIPT',        'local_links_actions');
define('LDM_ADMIN_SCRIPT',        'local_links_admin');
define('LDM_RESIZE_SCRIPT',        'local_resize');
define('LDM_SEARCH_SCRIPT',        'local_links_search');
define('LDM_STREAM_SCRIPT',        'local_stream');

// This definition should be set to one of
//        'navtab_start', 'navtab_middle' or 'navtab_end'
// according to the location you want the entry to LDM to appear on the main vB navbar.
// Set the definition to the null strong '' if you do not want the entry to appear at all.

define('LDM_NAVBAR_LOCATION',    'navtab_middle');

?>

3- "links_navbar" template
PHP Code:

<vb:if condition="$vbulletin->options['selectednavtab'] == 'ldm'">

<
li class="selected">
    <
class="navtab" href="{vb:raw LDM_scripts.LDM_LINKS_SCRIPT}.php{vb:raw session.sessionurl_q}">{vb:rawphrase ldm_vbmenu_ldm}</a>
    <
ul class="floatcontainer">
    <
li class="popupmenu">
    <
a href="javascript://" class="popupctrl">{vb:rawphrase ll_menu_cat}</a>
    <
ul class="popupbody popuphover">
    <
li>
    <
a href="{vb:raw LDM_scripts.LDM_LINKS_SCRIPT}.php?{vb:raw session.sessionurl_q}">{vb:rawphrase ll_menu_home}</a>
    </
li>
<
vb:if condition="$show['ldm_add_category'] and $viewcatid>-2">
    <
li>
    <
a href="{vb:raw LDM_scripts.LDM_LINKS_SCRIPT}.php?{vb:raw session.sessionurl_q}action=addcat&amp;catid={vb:raw  viewcatid}">{vb:rawphrase ll_menu_addcat}</a>
    </
li>
</
vb:if>
<
vb:if condition="$show['ldm_edit_category'] and $viewcatid>0">
    <
li>
    <
a href="{vb:raw LDM_scripts.LDM_LINKS_SCRIPT}.php?{vb:raw session.sessionurl_q}action=editcat&amp;catid={vb:raw  viewcatid}">{vb:rawphrase ll_menu_editcat}</a></li>
</
vb:if>
    </
ul>
    </
li>

<
vb:if condition="$show['ldm_add_multi']">
    <
li class="popupmenu">
    <
a href="javascript://" class="popupctrl">{vb:rawphrase ll_entries}</a>
    <
ul class="popupbody popuphover">
    <
li id="ldm_navbar_addmulti">
    <
form action="{vb:raw LDM_scripts.LDM_LINKS_SCRIPT}.php" method="get">
    {
vb:rawphrase ll_menu_addmulti}
    <
input type="text" name="numadd" size="3" value="{vb:raw links_defaults.allow_add_multi}" />
    <
input type="hidden" name="action" value="addmultilink" />
    <
input type="hidden" name="catid" value="{vb:raw viewcatid}" />
    <
input type="submit" value="{vb:rawphrase ll_go}" name="submit" />
    </
form>
    </
li>
    </
ul>
    </
li>
<
vb:elseif condition="$show['ldm_add_link']" />
    <
li>
    <
a href="{vb:raw LDM_scripts.LDM_LINKS_SCRIPT}.php?{vb:raw session.sessionurl}action=addlink&amp;catid={vb:raw viewcatid}">
    {
vb:rawphrase ll_menu_addlink}
    </
a>
    </
li>
</
vb:if>

    <
li class="popupmenu">
    <
a href="javascript://" class="popupctrl">{vb:rawphrase ll_menu_show}</a>
    <
ul class="popupbody popuphover">
<
vb:if condition="$show['ldm_mark_link']">
    <
li><a href="{vb:raw LDM_scripts.LDM_SEARCH_SCRIPT}.php?{vb:raw session.sessionurl}action=find&amp;catid={vb:raw LDM_cats.FAVS_CAT}">{vb:rawphrase ll_menu_showfav}</a></li>
</
vb:if>

<
vb:if condition="$show['ldm_add_link']">
    <
li><a href="{vb:raw LDM_scripts.LDM_SEARCH_SCRIPT}.php?{vb:raw session.sessionurl}action=find&amp;catid={vb:raw LDM_cats.MY_CAT}">{vb:rawphrase ll_menu_showmyl}</a></li>
</
vb:if>

<
vb:if condition="$show['ldm_star_links']">
    <
li><a href="{vb:raw LDM_scripts.LDM_SEARCH_SCRIPT}.php?{vb:raw session.sessionurl}action=find&amp;catid={vb:raw LDM_cats.NOM_CAT}">{vb:rawphrase ll_menu_shownominate}</a></li>
<
vb:if condition="$show['ldm_view_nominations']">
    <
li><a href="{vb:raw LDM_scripts.LDM_SEARCH_SCRIPT}.php?{vb:raw session.sessionurl}action=find&amp;catid={vb:raw LDM_cats.CNOM_CAT}">{vb:rawphrase ll_menu_showcnominate}</a></li>
</
vb:if>
</
vb:if>

    <
li><a href="{vb:raw LDM_scripts.LDM_SEARCH_SCRIPT}.php?{vb:raw session.sessionurl}action=find&amp;catid={vb:raw LDM_cats.HOT_CAT}">{vb:rawphrase ll_menu_showhot}</a></li>
    <
li><a href="{vb:raw LDM_scripts.LDM_SEARCH_SCRIPT}.php?{vb:raw session.sessionurl}action=find&amp;catid={vb:raw LDM_cats.NEW_CAT}">{vb:rawphrase ll_menu_shownew}</a></li>
    <
li><a href="{vb:raw LDM_scripts.LDM_SEARCH_SCRIPT}.php?{vb:raw session.sessionurl}action=find&amp;catid={vb:raw LDM_cats.NEW_RATE}">{vb:rawphrase ll_menu_shownewrating}</a></li>

    <
li><a href="{vb:raw LDM_scripts.LDM_SEARCH_SCRIPT}.php?{vb:raw session.sessionurl}action=find&amp;catid={vb:raw LDM_cats.RND_CAT}">{vb:rawphrase ll_menu_showrnd}</a></li>

<
vb:if condition="$show['ldm_admin_links']">
    <
li><a href="{vb:raw LDM_scripts.LDM_SEARCH_SCRIPT}.php?{vb:raw session.sessionurl}action=find&amp;catid={vb:raw LDM_cats.AVL_CAT}">{vb:rawphrase ll_menu_showavl}</a></li>
    <
li><a href="{vb:raw LDM_scripts.LDM_SEARCH_SCRIPT}.php?{vb:raw session.sessionurl}action=find&amp;catid={vb:raw LDM_cats.HIDE_CAT}">{vb:rawphrase ll_menu_showhid}</a></li>
    <
li><a href="{vb:raw LDM_scripts.LDM_SEARCH_SCRIPT}.php?{vb:raw session.sessionurl}action=find&amp;catid={vb:raw LDM_cats.BRKN_CAT}">{vb:rawphrase ll_menu_showbrk}</a></li>
    <
li><a href="{vb:raw LDM_scripts.LDM_SEARCH_SCRIPT}.php?{vb:raw session.sessionurl}action=find&amp;catid={vb:raw LDM_cats.INVD_CAT}">{vb:rawphrase ll_menu_showinv}</a></li>
    <
li><a href="{vb:raw LDM_scripts.LDM_SEARCH_SCRIPT}.php?{vb:raw session.sessionurl}action=find&amp;catid={vb:raw LDM_cats.UPLD_CAT}">{vb:rawphrase ll_menu_showupl}</a></li>
<
vb:if condition="$links_defaults['featured_user_favs']">
    <
li><a href="{vb:raw LDM_scripts.LDM_SEARCH_SCRIPT}.php?{vb:raw session.sessionurl}action=find&amp;catid={vb:raw LDM_cats.FEAT_CAT}">{vb:rawphrase ll_menu_showfeat}</a></li>
</
vb:if>
</
vb:if>

    </
ul>
    </
li>

<
vb:if condition="$show['ldm_search_quick']">
    <
li class="popupmenu">
    <
a href="javascript://" class="popupctrl">{vb:rawphrase ll_menu_search}</a>
    <
ul class="popupbody popuphover">
    <
li id="ldm_navbar_search">
        <
form action="{vb:raw LDM_scripts.LDM_SEARCH_SCRIPT}.php" method="get" id="ldm_search">
        {
vb:rawphrase ll_menu_search}
        <
input type="text" name="search" size="15" value="" />
        <
input type="submit" value="{vb:rawphrase ll_go}" name="submit" />
        <
input type="hidden" name="action" value="show" />
        <
input type="hidden" name="s" value="{vb:raw session.sessionhash}" />
        <
input type="hidden" name="literal" value="{vb:raw links_defaults.default_search_all}" />
        <
input type="hidden" name="desc"  value="<vb:if condition="$links_defaults['default_search_desc']">1<vb:else />0</vb:if>" />
        <
input type="hidden" name="keys"  value="<vb:if condition="$links_defaults['default_search_keys']">1<vb:else />0</vb:if>" />
        <
input type="hidden" name="ents"  value="<vb:if condition="$links_defaults['default_search_ents']">1<vb:else />0</vb:if>" />
        </
form>
        </
li>
        <
li><a href="{vb:raw LDM_scripts.LDM_SEARCH_SCRIPT}.php?{vb:raw session.sessionurl}action=search">{vb:rawphrase ll_advanced_search}</a></li>

        {
vb:raw ldm_mysavedsearch.menu}

        {
vb:raw ldm_myprofilesearch.menu}

    </
ul>
    </
li>
<
vb:elseif condition="$show['ldm_search_link']" />
    <
li><a href="{vb:raw LDM_scripts.LDM_SEARCH_SCRIPT}.php?{vb:raw session.sessionurl}action=search">{vb:rawphrase ll_menu_search}</a></li>
</
vb:if>

<
vb:if condition="$show['ldm_moderate_links']">
    <
li><a href="{vb:raw LDM_scripts.LDM_LINKS_SCRIPT}.php?{vb:raw session.sessionurl}action=mod">{vb:rawphrase ll_menu_mod}</a></li>
</
vb:if>

<
vb:if condition="$show['ldm_admin_links']">
    <
li><a href="{vb:raw LDM_scripts.LDM_ADMIN_SCRIPT}.php?{vb:raw session.sessionurl}action=admin">{vb:rawphrase ll_menu_admin} {vb:raw LDM_Version}</a></li>
</
vb:if>

    </
ul>
</
li>
<
vb:else />
<
li><class="navtab" href="{vb:raw ldm_links_script}.php{vb:raw session.sessionurl_q}">{vb:rawphrase ldm_vbmenu_ldm}</a></li>
</
vb:if> 


the problem Now , the variable is not registered like {vb:raw ldm_links_script} >> doesn't get the file name > thats make all links on the script ""when use the template" is invalid like this
http://localhost/vb/.php // Links and Download Main links
http://localhost/vb/.php?action=mod
http://localhost/vb/.php?action=admin



Please don't delete this post, the programer for this script will not help anymore, I searched alot to fix this problem but I can't fix it
BTW: this problem only available in vb4.2.0 , and not present in 4.1.x , don't know what is the reason

jimsflies 04-10-2013 02:14 PM

Hopefully someone can help here... I am beginning the daunting task of upgrading from vb3.8 to vb4. My forumhome uses a variable "$forumbitcounter" which is calculated in a plugin which contains the following code:

Code:

$forumbitcounter++;
What do I need to do to get this variable working on forumhome in vb4?

Lynne 04-10-2013 03:23 PM

Quote:

Originally Posted by jimsflies (Post 2415528)
Hopefully someone can help here... I am beginning the daunting task of upgrading from vb3.8 to vb4. My forumhome uses a variable "$forumbitcounter" which is calculated in a plugin which contains the following code:

Code:

$forumbitcounter++;
What do I need to do to get this variable working on forumhome in vb4?

You need to then preregister it for use in the FORUMHOME template (I assume that is the template you are using it in?)
PHP Code:

vB_Template::preRegister('FORUMHOME', array('forumbitcounter' => $forumbitcounter)); 


jimsflies 04-10-2013 04:08 PM

Quote:

Originally Posted by Lynne (Post 2415543)
You need to then preregister it for use in the FORUMHOME template (I assume that is the template you are using it in?)
PHP Code:

vB_Template::preRegister('FORUMHOME', array('forumbitcounter' => $forumbitcounter)); 


This is prolly a dumb question but was the major one I had reading the original post of this article... Does the registration code go in the forum home template or in a plugin?

Also the variable is actually used in the forumhome_forumbit_level1_post template so would it need to be registered there or would registering it in the containing template be okay?

Lynne 04-10-2013 04:43 PM

That code goes in the plugin right after your code that defines the variable. And if the variable is in the forumhome_forumbit_level1_post template template, then it needs to be:

PHP Code:

$forumbitcounter++;
vB_Template::preRegister('forumhome_forumbit_level1_post', array('forumbitcounter' => $forumbitcounter)); 


jimsflies 04-10-2013 04:55 PM

Thanks Lynne got it to work... I tried to like your post but got a message saying I have to like someone else's before liking any more of yours lol.

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

One other quick issue...I think this is due to the array (which I didn't have to use in vb3), the first value appears to be null, but needs to start with 1. How do I tell it to start with a value of 1?

Lynne 04-10-2013 10:34 PM

I'm not sure I understand... what are you using in the template for the variable? It should just be $variable or {vb:raw variable}

ezak 04-11-2013 05:20 AM

I found where is the problem, thanks :)

jimsflies 04-11-2013 07:37 PM

Quote:

Originally Posted by Lynne (Post 2415632)
I'm not sure I understand... what are you using in the template for the variable? It should just be $variable or {vb:raw variable}

I thought I had a fix yesterday, but it still isn't quite right. What I am doing is creating a counter for styling the forum home page. Using this counter in my template creates the alternating background shading and creates the two column layout as seen in my current vb3 site here: http://www.captivereefs.com/forum/forums.html

The problem seems to be on the first forumbitcount the value isn't 1 (I guess it is zero or is empty). Then the second forumbitcount is equal to 1 but should be 2.

Lynne 04-11-2013 10:05 PM

The variable needs to get preregistered for use in the template *after* is it defined, just like I had posted it above:

PHP Code:

$forumbitcounter++;
vB_Template::preRegister('forumhome_forumbit_level1_post', array('forumbitcounter' => $forumbitcounter)); 



All times are GMT. The time now is 12:22 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.02225 seconds
  • Memory Usage 2,063KB
  • 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
  • (22)bbcode_code_printable
  • (9)bbcode_php_printable
  • (11)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (3)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (40)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