The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
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> |
#2
|
|||
|
|||
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. |
2 благодарности(ей) от: | ||
deverill2010, Lynne |
#3
|
|||
|
|||
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. |
#4
|
|||
|
|||
Edit: don't change the cache time. But you need to add a line of code:
Code:
global $show; just above the "if" line. |
#5
|
|||
|
|||
That works perfect! Thank you so much kh99
|
#6
|
|||
|
|||
I seem to have an issue.
Every time I enable this block with this code in it. It throws my site into 'internal error'? |
#7
|
||||
|
||||
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.
|
#8
|
|||
|
|||
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. |
#9
|
||||
|
||||
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? |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|