PDA

View Full Version : if condition in bbcode_code template


al3loo
12-08-2010, 01:10 PM
Hi,

I am trying to add if condition in bbcode_code template, but it seem not working well !

For example: I want to show a message for groups (2,5,6,7) inside the code <pre> .. its not work proparly! .. it will show even for guest so the if is not working

<div class="bbcode_container">
<div class="bbcode_description">{vb:rawphrase code}:</div>
<pre class="bbcode_code"<vb:if condition="$vboptions['codemaxlines']">style="height:<vb:if condition="$blockheight<$vboptions['codemaxlines']">{vb:math {vb:raw blockheight}*{vb:stylevar mid_fontSize}+{vb:stylevar mid_fontSize}*2}<vb:else />{vb:math {vb:raw blockheight}*{vb:stylevar mid_fontSize}+{vb:stylevar mid_fontSize}}</vb:if>;"</vb:if>><vb:if condition="is_member_of($bbuserinfo,2,5,6,7)">Test message</vb:if>{vb:raw code}</pre>
</div>

I tried even simple one like:
<vb:if condition="$show['member']">I am member<vb:else />I am not member</vb:if>

But it shows the same result for users and guest.
Am I doing something wrong !!

Best Regards,

Lynne
12-08-2010, 01:34 PM
If you have post parsing turned on, then the bbcode all gets parsed into the post and is fed from the post parsed table. You can't apply a condition to it at that time.

al3loo
12-08-2010, 04:15 PM
I'm not sure if I clearly understand you but what do you mean with post parsing, and where could I turned it off and what it should do.

Lynne
12-08-2010, 10:13 PM
Try vboptions > server settings > cached posts lifespan. Set that to 0.
Cached Posts Lifespan

Posts are normally stored with BB code tags etc. in the same form as the user posted them with so that it may be edited later, and then parsed at display time. By caching them, they are parsed at post time (instead of display time) into the HTML they will be displayed in and stored separately from the pre-parsed posts. This results in a faster display on threads, since the posts do not have to be parsed at display time.

This option determines how long posts are stored. While a post is cached, it will take approximately twice as much storage space since it is essentially being stored twice. If you have a busy site, and threads typically don't last very long, you can probably set this to a lower value such as 10 days. If you have a slower site, and threads typically last longer, 20 to 30 days might be a better choice. If you have the disc space, you can set this to a higher value for better performance.

al3loo
12-09-2010, 10:48 AM
Edit: It works after a while !
But why should I remove the cache at all .. is there any other way just to remove this template from the cache?!

I guess it should not be related with any cache .. bacause I am just trying to add an IF .. and it should works fine just like how it works in header or navbar template. Otherwise, those variables and functions ($show / is_member_of()) are not related/connected with all templates OR maybe this is a bug?!

Lynne
12-09-2010, 02:07 PM
The caching is only *post* caching. It's done to make your site faster by parsing all the bbcode at save time, rather than post time. That way it's done once and not every time the post is called. It isn't some bug, it is what that function does.