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

Reply
 
Thread Tools Display Modes
  #1  
Old 01-19-2013, 03:47 PM
deverill2010 deverill2010 is offline
 
Join Date: Jan 2011
Posts: 412
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default vb condition in a forum block

How would I go about getting the following to work in a forum block? As vb conditions don't seem to work how i've written it.

Code:
<center><a href="http://www.midwiferyonline.co.uk/store/index.php/midwife-in-the-making-hoodie-7/hoodies.html">
<img src="http://www.midwiferyonline.co.uk/images/ads/members10discount.jpg" alt="10% OFF Hoodies" width="180" height="220"></a>
<br /><br />
<vb:if condition="$show['guest']">
<a href="http://www.midwiferyonline.co.uk/register.php">Register</a> or <a href="http://www.midwiferyonline.co.uk/login.php?do=login">Login</a>
<vb:else />
<img src="http://www.midwiferyonline.co.uk/images/ads/members10discountcoupon.jpg" alt="10% OFF Hoodies" width="155" height="166"></a></vb:if></center>
Reply With Quote
  #2  
Old 01-19-2013, 04:00 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You can use a php type block and make the html into strings (and the condition would then be a php 'if'), like:

Code:
$output = '<center><a href="http://www.midwiferyonline.co.uk/store/index.php/midwife-in-the-making-hoodie-7/hoodies.html">
<img src="http://www.midwiferyonline.co.uk/images/ads/members10discount.jpg" alt="10% OFF Hoodies" width="180" height="220"></a>
<br /><br />';
global $show;
if ($show['guest'])
{
    $output .= '<a href="http://www.midwiferyonline.co.uk/register.php">Register</a> or <a href="http://www.midwiferyonline.co.uk/login.php?do=login">Login</a>';
}
else
{
    $output .= '<img src="http://www.midwiferyonline.co.uk/images/ads/members10discountcoupon.jpg" alt="10% OFF Hoodies" width="155" height="166"></a>';
}
$output .= '</center>';

return $output;

You could also create a template for your output then use code to render the template. And another way would be to copy the block_html template to a new template, insert your code, then enter your new template name in the "Template To Use" field.
Reply With Quote
2 благодарности(ей) от:
deverill2010, Lynne
  #3  
Old 01-19-2013, 04:24 PM
deverill2010 deverill2010 is offline
 
Join Date: Jan 2011
Posts: 412
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thank you! I've never been sure of the strings to use.

I just tried the above in my block and it shows the image great when logged in, however it doesn't revert to the links when logged out, you still the image. hmm.
Reply With Quote
  #4  
Old 01-19-2013, 07:07 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Edit: don't change the cache time. But you need to add a line of code:
Code:
global $show;

just above the "if" line.
Reply With Quote
  #5  
Old 01-20-2013, 08:02 AM
deverill2010 deverill2010 is offline
 
Join Date: Jan 2011
Posts: 412
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

That works perfect! Thank you so much kh99
Reply With Quote
  #6  
Old 01-23-2013, 03:58 PM
deverill2010 deverill2010 is offline
 
Join Date: Jan 2011
Posts: 412
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I seem to have an issue.

Every time I enable this block with this code in it. It throws my site into 'internal error'?
Reply With Quote
  #7  
Old 01-23-2013, 04:38 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I just used the code in post 2 on my site in a PHP forum block and it works just fine. I'd suggest you delete the block and add it again.
Reply With Quote
  #8  
Old 01-23-2013, 07:02 PM
deverill2010 deverill2010 is offline
 
Join Date: Jan 2011
Posts: 412
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I've just tried that Lynne and now joy.

It must be a configuration issue server side then as I've had an internal error for the last 19 hours, which is has been resolved and my website is back up. I just not get the internal server error when I enable that block.

Strange.
Reply With Quote
  #9  
Old 01-23-2013, 08:53 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Check your error_logs (if you don't know where they are, ask your host). Also, see if you have mod_security or suhosin on the server.

You are using a PHP type, right? And this is a forum block?
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 12:04 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.04042 seconds
  • Memory Usage 2,239KB
  • Queries Executed 11 (?)
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_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (9)post_thanks_box
  • (2)post_thanks_box_bit
  • (9)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit
  • (9)post_thanks_postbit_info
  • (9)postbit
  • (9)postbit_onlinestatus
  • (9)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_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
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete