vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   Subtract part of BBCode using vB_BbCodeParser (https://vborg.vbsupport.ru/showthread.php?t=323840)

zero477 11-08-2016 04:23 PM

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?

noypiscripter 11-09-2016 11:49 PM

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.

zero477 11-11-2016 03:44 PM

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.

MarkFL 11-11-2016 04:16 PM

Quote:

Originally Posted by zero477 (Post 2578111)
...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. :)

noypiscripter 11-12-2016 12:46 AM

Quote:

Originally Posted by zero477 (Post 2578111)
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%;
}



All times are GMT. The time now is 08:20 AM.

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.01192 seconds
  • Memory Usage 1,734KB
  • 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
  • (3)bbcode_code_printable
  • (1)bbcode_html_printable
  • (2)bbcode_php_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (5)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