vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   if condition in bbcode_code template (https://vborg.vbsupport.ru/showthread.php?t=254868)

al3loo 12-08-2010 01:10 PM

if condition in bbcode_code template
 
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

PHP Code:

<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:
PHP Code:

<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.
Quote:

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.


All times are GMT. The time now is 05:07 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.01068 seconds
  • Memory Usage 1,730KB
  • 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
  • (2)bbcode_php_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (6)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