Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 11-08-2016, 04:23 PM
zero477 zero477 is offline
 
Join Date: Jan 2012
Posts: 59
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Subtract part of BBCode using vB_BbCodeParser

Hello to all,

I want to print part of a post using (like the first 100 words) the vB_BbCodeParser. If I use PHP sometimes I cut thre string in the middle of somewhere where I should not and I cannot display the html correctly.

For example:

PHP Code:

    $bbcode_parser 
=& new vB_BbCodeParser(vb::$vbulletinfetch_tag_list(), true); 
    
$text'
            <div class="review-text">
                    &quot;'
.substr($bbcode_parser->parse($opiniones["pagetext"]), 0400).'...<a href="threads/'.$opiniones["threadid"].'-'.urlencode($opiniones["thread_title"]).'?p='.$opiniones["postid"].'#post'.$opiniones["postid"].'">ver m?s</a>...&quot; 
    
                </div>

echo $text; 


Here, the link does not work because I cut the code incorrectly.

HTML Code:
<span style="font-fam...<a href="thr
Any ideas?
Reply With Quote
  #2  
Old 11-09-2016, 11:49 PM
noypiscripter's Avatar
noypiscripter noypiscripter is offline
 
Join Date: Jul 2013
Posts: 468
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Is this for vB5? Looks likes not.

Anyway, why not let the browser (via CSS) truncate the text and add ellipsis (...) depending on how wide the container of the text is?

PHP Code:
$bbcode_parser =& new vB_BbCodeParser(vb::$vbulletinfetch_tag_list(), true); 
$text'
    <div class="review-text">
        &quot;<span class="pagetext h-inline-block ellipsis">' 
$opiniones["pagetext"] . '</span><a href="threads/'.$opiniones["threadid"].'-'.urlencode($opiniones["thread_title"]).'?p='.$opiniones["postid"].'#post'.$opiniones["postid"].'">ver m?s</a>...&quot; 
    </div>
    '
;
echo 
$text
Then add this in additional css:
Code:
.review-text .pagetext { width: 90%; }
vB5 has helper css classes ellipsis and h-inline-block to easily make an element behave like a text with ellipsis.
Reply With Quote
Благодарность от:
MarkFL
  #3  
Old 11-11-2016, 03:44 PM
zero477 zero477 is offline
 
Join Date: Jan 2012
Posts: 59
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hello noypiscripter and thank you for your answer.

You are right, I am using vB 4 i posted in the wrong forum (Im sorry, hope that the moderators move this thread to the correct place).

Ill check if your solution works.
Reply With Quote
Благодарность от:
MarkFL
  #4  
Old 11-11-2016, 04:16 PM
MarkFL's Avatar
MarkFL MarkFL is offline
 
Join Date: Feb 2014
Location: St. Augustine, FL
Posts: 3,853
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by zero477 View Post
...You are right, I am using vB 4 i posted in the wrong forum (Im sorry, hope that the moderators move this thread to the correct place)...
I've moved the thread, and in the future if you discover you have posted in the wrong forum, please feel free to use our post reporting feature to bring it to the attention of the moderating staff and request that the thread be moved. This will increase the odds that it will be moved.
Reply With Quote
  #5  
Old 11-12-2016, 12:46 AM
noypiscripter's Avatar
noypiscripter noypiscripter is offline
 
Join Date: Jul 2013
Posts: 468
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by zero477 View Post
Hello noypiscripter and thank you for your answer.

You are right, I am using vB 4 i posted in the wrong forum (Im sorry, hope that the moderators move this thread to the correct place).

Ill check if your solution works.
In that case, remove the h-inline-block and ellipsis css classes in the span tag and then replace this css in additional css:

Code:
.review-text .pagetext { width: 90%; }
with:

Code:
.review-text .pagetext {
    display: inline-block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 90%;
}
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 04:49 AM.


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.10304 seconds
  • Memory Usage 2,222KB
  • Queries Executed 13 (?)
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
  • (3)bbcode_code
  • (1)bbcode_html
  • (2)bbcode_php
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (5)post_thanks_box
  • (2)post_thanks_box_bit
  • (5)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (2)post_thanks_postbit
  • (5)post_thanks_postbit_info
  • (5)postbit
  • (5)postbit_onlinestatus
  • (5)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_postinfo_query
  • fetch_postinfo
  • 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
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete