vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   Help on using conditionals based on the length of first post in a thread (https://vborg.vbsupport.ru/showthread.php?t=101451)

Neutral Singh 11-24-2005 08:57 AM

Help on using conditionals based on the length of first post in a thread
 
Hi

I am talking about only the very first post in any thread.

Suppose, I have a thread with more 1,000 characters in 'showthread' template. I want to place a conditional statement in the postbit template so that if the length of first post is less than say '500' characters then a statement is executed otherwise another.

For Example

Code:



<if condition="length of the post < 500 characters" >

      Execute a statement

      <else />

              <if condition="length of the post < 700 characters" >

              Execute a statement

              <else />

              Execute a statement for all posts > 700 characters.

              <if/>

</if>

I am looking for that conditional statement that can perform this function.



Thanks in advance



Best Regards

Marco van Herwaarden 11-24-2005 09:20 AM

With 'statement' you mean display a text, or execute coding? Coding can not be executed in a template.

Anyway, what you are trying to do can be done in a Plugin, not in a template, unless you want to write cstom JavaScript coding.

Neutral Singh 11-24-2005 09:53 AM

Yes, i want to show different text messages on meeting the criteria. Is there any similar plugin available? Could not find one like this one. Thanks

merk 11-24-2005 10:45 AM

Try putting the below into postbit_display_start

PHP Code:

if($post['postcount'] == 1)
{
$post['text_length'] = strlen($post['message']);


Then, using conditionals

HTML Code:

<if condition="$post['postcount'] == 1">
 <if condition="$post['text_length'] <= 500">This message is less than or equal  to 500 characters
 <else />
 <if condition="$post['text_length'] <= 700">so on
 <else />
 etc.....
 </if>
 </if>
</if>


Neutral Singh 11-25-2005 04:33 AM

Its not working as desired. It is not calculating the character length of the message for showing the conditional text message.

In the postbit template i am using the following statement

<if condition="$post['text_length'] <= 500">
OUTPUT ONE

<else />
OUTPUT TWO

</if>

I have tried changing <= 500 characters to 1 and 5 or even 500000 but it produces only one output ie. OUTPUT ONE, which is not the desired result. Further guidance required, please.

Adding following code in the plugin produces 000 on the screen.
--> echo strlen($text_length);

merk 11-25-2005 10:20 AM

Try changing the plugin to

PHP Code:

if($post['postcount'] == 1)
{
$post['text_length'] = strlen($post['message']);
echo 
$post['text_length']; die;


It will halt script execution and noone will be able to view threads, so once you get a result revert it or disable it.

Neutral Singh 11-25-2005 02:39 PM

The result echoed was 0

merk 11-25-2005 08:33 PM

Ill take a look later this afternoon, 'message' is obviously wrong.

Marco van Herwaarden 11-25-2005 09:32 PM

Maybe just add a global $post

Neutral Singh 11-26-2005 06:06 AM

Please do it, i am counting upon you. :)


All times are GMT. The time now is 03:57 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.01040 seconds
  • Memory Usage 1,736KB
  • 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
  • (1)bbcode_code_printable
  • (1)bbcode_html_printable
  • (2)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)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
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete