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

Reply
 
Thread Tools Display Modes
  #1  
Old 11-24-2009, 08:58 AM
micheal332001 micheal332001 is offline
 
Join Date: Apr 2004
Posts: 1,112
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default 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
Reply With Quote
  #2  
Old 11-24-2009, 10:21 AM
Paul M's Avatar
Paul M Paul M is offline
 
Join Date: Sep 2004
Location: Nottingham, UK
Posts: 23,748
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Have you registered the variables for use in the template ?
Reply With Quote
  #3  
Old 11-24-2009, 10:39 AM
micheal332001 micheal332001 is offline
 
Join Date: Apr 2004
Posts: 1,112
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Paul M View Post
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.
Reply With Quote
  #4  
Old 11-24-2009, 10:46 AM
ragtek ragtek is offline
 
Join Date: Mar 2006
Location: austria, croatia
Posts: 1,630
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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']">
Reply With Quote
  #5  
Old 11-24-2009, 11:02 AM
xman_79's Avatar
xman_79 xman_79 is offline
 
Join Date: Jun 2006
Location: Romania
Posts: 65
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply With Quote
  #6  
Old 11-24-2009, 11:23 AM
ragtek ragtek is offline
 
Join Date: Mar 2006
Location: austria, croatia
Posts: 1,630
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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); 
Reply With Quote
  #7  
Old 11-24-2009, 12:09 PM
micheal332001 micheal332001 is offline
 
Join Date: Apr 2004
Posts: 1,112
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by xman_79 View Post
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.
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 02:17 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.04073 seconds
  • Memory Usage 2,281KB
  • 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
  • (2)bbcode_code
  • (5)bbcode_html
  • (6)bbcode_php
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (7)post_thanks_box
  • (7)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (7)post_thanks_postbit_info
  • (7)postbit
  • (7)postbit_onlinestatus
  • (7)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
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete