vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   Modification Requests/Questions (Unpaid) (https://vborg.vbsupport.ru/forumdisplay.php?f=112)
-   -   Thread preview formatting (https://vborg.vbsupport.ru/showthread.php?t=281154)

Morrus 04-05-2012 01:22 PM

Thread preview formatting
 
Hopefully this is an easy question. I've hunted around here and couldn't find a solution.

I'm using vbulletin 3.8.7. and vBadvanced 3.2.2.

I've set up an RSS "megafeed" page which uses the vBadvanced "latest threads" module to combine a dozen or so RSS feeds into one page. You can see it here.

I've moved the thread preview text so it appears automatically after the title, rather than only on mouseover. So far so good; all working fine.

My problem, as you can see from the linked page, is the formatting of the thread preview text. If there is an image, or some slightly dodgy html in the original RSS feed, you see the image URL or some html tags, which is ugly as heck.

For example, you can see things like:

Code:

Conquest Day Monday, April 2, 2012 http://www.enworld.org/image/content/PathfinderSociety/PZO9226-Nex_180.jpeg Illustration by Dave Rapoza I almost lined this holiday boon up perfectly with its in-game date and real-world date. When I realized it was my 6-month anniversary (wow, time...
and

Code:

Unless you come here at least a few times a month, you will not likely notice it, but I have made some changes here on site last night and today. I wanted to take some time and explain why they (…)</p>Read the rest of this entry ? More...
So what I need to do is display JUST the text. No image URLs, no html tags, etc.

Any ideas?

BirdOPrey5 04-06-2012 09:53 AM

Basically you'd need to make a plugin on some hook that you can intercept the preview text and clean it with various php functions.

You can probably remove most of the HTML tags like <p> , </p>, <br />, etc... using the str_ireplace function.

Code:

$clean_array = array ('<p>', '</p>', '<br />', '<h1>', '</h1>');
$text = str_ireplace($clean_array, '', $text);

Of course you'd want to add a lot more HTML tags to that array...

However you'd still be stuck with images... For those you'd probably need to make a regex to find patterns and remove them with preg_replace.

But since this stuff is all happening in a VBAdvanced product I have no idea what the actual hook you need to use is.

Morrus 04-08-2012 03:48 PM

Thanks.

Sounds like it's a harder job than I thought it would be.

kh99 04-08-2012 03:55 PM

There is something used in the RSS feed (external.php) among other places. It looks like this:

Code:

require_once(DIR . '/includes/class_bbcode_alt.php');
$plaintext_parser = new vB_BbCodeParser_PlainText($vbulletin, fetch_tag_list($vbulletin->options['bburl'] . '/'));
$plaintext = $plaintext_parser->parse($message, $forumid);


(I copied this from external.php and modified it slightly, so I don't know why it uses $vbulletin->options['bburl'] or what the $forumid is used for).

BirdOPrey5 04-08-2012 05:09 PM

I found out there is also a strip_tags() php function that will remove HTML taga, don't need to worry about str_ireplace().

Morrus 04-09-2012 04:46 PM

Quote:

Originally Posted by BirdOPrey5 (Post 2318083)
I found out there is also a strip_tags() php function that will remove HTML taga, don't need to worry about str_ireplace().

How would I use such a function?

It would certainly help! Wouldn't solve all the problems, but would help with some of 'em!

BirdOPrey5 04-09-2012 09:54 PM

Like I said before it;s vbadvanced so I have no clue what hook you'd need, you can probably ask over at the vbadvanced forums. It may take a few days but Brian will usually answer in my experience.

Once you find the hook and the variable that holds the text of the preview, for example let's say it is $text, then you simply make a new plugin (ACP -> Plugin Manager -> Add new plugin) on the specific hook with this code:
PHP Code:

$text strip_tags($text); 

And that will output the $text minus any HTML tags.


All times are GMT. The time now is 08:23 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.01611 seconds
  • Memory Usage 1,730KB
  • 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
  • (4)bbcode_code_printable
  • (1)bbcode_php_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (7)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