vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=251)
-   -   vb condition in a forum block (https://vborg.vbsupport.ru/showthread.php?t=294113)

deverill2010 01-19-2013 03:47 PM

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>


kh99 01-19-2013 04:00 PM

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.

deverill2010 01-19-2013 04:24 PM

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.

kh99 01-19-2013 07:07 PM

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

global $show;

just above the "if" line.

deverill2010 01-20-2013 08:02 AM

That works perfect! Thank you so much kh99 :)

deverill2010 01-23-2013 03:58 PM

I seem to have an issue.

Every time I enable this block with this code in it. It throws my site into 'internal error'?

Lynne 01-23-2013 04:38 PM

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.

deverill2010 01-23-2013 07:02 PM

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.

Lynne 01-23-2013 08:53 PM

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?


All times are GMT. The time now is 03:29 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.01274 seconds
  • Memory Usage 1,723KB
  • 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
  • (3)bbcode_code_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (9)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