Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 11-24-2005, 08:57 AM
Neutral Singh's Avatar
Neutral Singh Neutral Singh is offline
 
Join Date: Sep 2004
Location: Sikh Philosophy Network
Posts: 545
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default 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
Reply With Quote
  #2  
Old 11-24-2005, 09:20 AM
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
Posts: 25,415
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #3  
Old 11-24-2005, 09:53 AM
Neutral Singh's Avatar
Neutral Singh Neutral Singh is offline
 
Join Date: Sep 2004
Location: Sikh Philosophy Network
Posts: 545
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply With Quote
  #4  
Old 11-24-2005, 10:45 AM
merk merk is offline
 
Join Date: Nov 2001
Location: Canberra, Australia
Posts: 601
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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>
Reply With Quote
  #5  
Old 11-25-2005, 04:33 AM
Neutral Singh's Avatar
Neutral Singh Neutral Singh is offline
 
Join Date: Sep 2004
Location: Sikh Philosophy Network
Posts: 545
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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);
Reply With Quote
  #6  
Old 11-25-2005, 10:20 AM
merk merk is offline
 
Join Date: Nov 2001
Location: Canberra, Australia
Posts: 601
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #7  
Old 11-25-2005, 02:39 PM
Neutral Singh's Avatar
Neutral Singh Neutral Singh is offline
 
Join Date: Sep 2004
Location: Sikh Philosophy Network
Posts: 545
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

The result echoed was 0
Reply With Quote
  #8  
Old 11-25-2005, 08:33 PM
merk merk is offline
 
Join Date: Nov 2001
Location: Canberra, Australia
Posts: 601
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Ill take a look later this afternoon, 'message' is obviously wrong.
Reply With Quote
  #9  
Old 11-25-2005, 09:32 PM
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
Posts: 25,415
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Maybe just add a global $post
Reply With Quote
  #10  
Old 11-26-2005, 06:06 AM
Neutral Singh's Avatar
Neutral Singh Neutral Singh is offline
 
Join Date: Sep 2004
Location: Sikh Philosophy Network
Posts: 545
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Please do it, i am counting upon you.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 12:23 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04818 seconds
  • Memory Usage 2,261KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)bbcode_code
  • (1)bbcode_html
  • (2)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete