vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   if condition problem (https://vborg.vbsupport.ru/showthread.php?t=228760)

micheal332001 11-24-2009 08:58 AM

if condition problem
 
I have a problem with this

HTML Code:

<vb:if condition="$gameinfo[uid] == $userid">
i have both these vars in the PHP file and show when i put print but they dont work in the html if condition statment.

If i put this in like so

HTML Code:

<vb:if condition="{vb:var gameinfouid}
you get an error page show when trying to save the template.

Could you please let me know how to get my vars to work in the new template system.

HTML Code:

$gameinfo[uid] == $userid

Paul M 11-24-2009 10:21 AM

Have you registered the variables for use in the template ?

micheal332001 11-24-2009 10:39 AM

Quote:

Originally Posted by Paul M (Post 1920055)
Have you registered the variables for use in the template ?

you cannot use this {vb:var gameinfouid} in a if statment you will get errors when saving the template.

ragtek 11-24-2009 10:46 AM

I think you have to make the second condition on php side;)

PHP Code:

if (gameinfo[uid] == $userid)
{
$show['foo'] == true;


And then in template
HTML Code:

<vb:if condition="$show['foo']">

xman_79 11-24-2009 11:02 AM

why not use in your php file

PHP Code:

$show['something'] = iif($gameinfo[uid] == $userid true flase); 

and in your template

Code:

<vb:if condition="$show['something']">
html code ....
</vb:if>

Edit : excuse me ragtek I saw your answer later

ragtek 11-24-2009 11:23 AM

I wouldn't use iif, use instead the ternary operator because iif is deprecated;)
PHP Code:

// #############################################################################
/**
* Essentially a wrapper for the ternary operator.
*
* @deprecated    Deprecated as of 3.5. Use the ternary operator.
*
* @param    string    Expression to be evaluated
* @param    mixed    Return this if the expression evaluates to true
* @param    mixed    Return this if the expression evaluates to false
*
* @return    mixed    Either the second or third parameter of this function
*/
function iif($expression$returntrue$returnfalse ''

PHP Code:

$show['foo'] = ($gameinfo['id'] == $userid truefalse); 


micheal332001 11-24-2009 12:09 PM

Quote:

Originally Posted by xman_79 (Post 1920073)
why not use in your php file

PHP Code:

$show['something'] = iif($gameinfo[uid] == $userid true flase); 

and in your template

Code:

<vb:if condition="$show['something']">
html code ....
</vb:if>

Edit : excuse me ragtek I saw your answer later

I have tryed this and if i put a echo or print on the $show['something'] it will show if its true or flase,
but in the template its not seeing it and outputting the info its showing it as $show['something'].

here is my PHP code

PHP Code:


$show
['something'] = iif($gameinfo[uid] == $userid true flase);  

    
$templater vB_Template::create('gamesswap_left_block_bit');
    
$templater->register('lm_catslist'$lm_catslist);
    
$templater->register('lm_myaccount'$lm_myaccount);
    
$left_block .= $templater->render();

    
$templater vB_Template::create('gamesswap_featured_block_bit');
    
$templater->register('cb_newestgames'$cb_newestgames);
    
$templater->register('cb_topseller'$cb_topseller);
    
$featured_block .= $templater->render();

    
$templater vB_Template::create('gamesswap_view_game_page_bit');
    
$templater->register('gname'$gameinfo[gname]);
    
$templater->register('gimage'$gameinfo[image]);
    
$templater->register('gdescription'$gdescription);
    
$templater->register('gaurther'$gameinfo[aurther]);
    
$templater->register('gpub'$gameinfo[pub]);
    
$templater->register('gameregion'$gameregion);
    
$templater->register('gcondition'$gameinfo[condition]);
    
$templater->register('ggage'$gameinfo[gage]);
    
$templater->register('ginstructions'$gameinfo[instructions]);
    
$templater->register('pictures'$pictures);
    
$templater->register('gswap1'$swaplist[swap1]);
    
$templater->register('gswap2'$swaplist[swap2]);
    
$templater->register('gswap3'$swaplist[swap3]);
    
$templater->register('gswap4'$swaplist[swap4]);
    
$templater->register('gswap5'$swaplist[swap5]);
    
$templater->register('gswap6'$swaplist[swap6]);
    
$templater->register('swap_status'$gameinfo[swap_status]);
    
$templater->register('gid'$gameinfo[gid]);
    
$current .= $templater->render();

    
$templater vB_Template::create('gamesswap');
    
$templater->register_page_templates();
      
$navbits construct_navbits(array("gamesswap.php?" $vbulletin->session->vars['sessionurl'] => $page_title));
      
$navbar render_navbar_template($navbits);
    
$templater->register('navbar'$navbar);
    
$templater->register('page_title'$page_title);
    
$templater->register('current'$current);
    
$templater->register('cm_catslist'$cm_catslist);
    
$templater->register('left_block'$left_block);
    
$templater->register('lm_search'$lm_search);
    
$templater->register('featured_block'$featured_block);
    
print_output($templater->render()); 

Here is my template code

HTML Code:


  <vb:if condition="$show['something']">
  <vb:else />
<table border="0" width="100%" align="center">
  <tr>
    <td colspan="2" class="blocksubhead" width="50%" align="center">{vb:raw vbphrase.options}</td>
</tr>
  <tr>
    <td class="alt1" width="50%" align="center"><vb:if condition="$swap_status1 > 1">
    {vb:raw swap_status}
  <vb:else />
    <form action="gamesswap.php?do=swap" method="post" enctype="multipart/form-data" target="_self">
<input type="hidden" name="gid" value="{vb:raw gid}">
<input type="submit" value="{vb:raw vbphrase.gamesswap_view_game_swap}">
</form>
  </vb:if>
</td>
    <td class="alt1" width="50%" align="center">
    <form action="gamesswap.php?do=question" method="post" enctype="multipart/form-data" target="_self">
<input type="hidden" name="gid" value="{vb:raw gid}">
<input type="submit" value="{vb:raw vbphrase.gamesswap_view_game_question}">
</form>
</td>
  </tr>
</table>
</vb:if>

But the if statment is still not working.


All times are GMT. The time now is 01:21 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.01246 seconds
  • Memory Usage 1,784KB
  • 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
  • (2)bbcode_code_printable
  • (5)bbcode_html_printable
  • (6)bbcode_php_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (7)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
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete