The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
||||
|
||||
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> Thanks in advance Best Regards |
#2
|
|||
|
|||
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. |
#3
|
||||
|
||||
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
|
#4
|
|||
|
|||
Try putting the below into postbit_display_start
PHP Code:
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> |
#5
|
||||
|
||||
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); |
#6
|
|||
|
|||
Try changing the plugin to
PHP Code:
|
#7
|
||||
|
||||
The result echoed was 0
|
#8
|
|||
|
|||
Ill take a look later this afternoon, 'message' is obviously wrong.
|
#9
|
|||
|
|||
Maybe just add a global $post
|
#10
|
||||
|
||||
Please do it, i am counting upon you.
|
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|