View Full Version : vb condition in a forum block
deverill2010
01-19-2013, 03:47 PM
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.
<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>
You can use a php type block and make the html into strings (and the condition would then be a php 'if'), like:
$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.
Edit: don't change the cache time. But you need to add a line of 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?
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.