Go Back   vb.org Archive > Community Discussions > Modification Requests/Questions (Unpaid)
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 04-05-2012, 02:22 PM
Morrus Morrus is offline
 
Join Date: Jan 2002
Posts: 494
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default 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?
Reply With Quote
  #2  
Old 04-06-2012, 10:53 AM
BirdOPrey5's Avatar
BirdOPrey5 BirdOPrey5 is offline
Senior Member
 
Join Date: Jun 2008
Location: New York
Posts: 10,610
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #3  
Old 04-08-2012, 04:48 PM
Morrus Morrus is offline
 
Join Date: Jan 2002
Posts: 494
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks.

Sounds like it's a harder job than I thought it would be.
Reply With Quote
  #4  
Old 04-08-2012, 04:55 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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).
Reply With Quote
  #5  
Old 04-08-2012, 06:09 PM
BirdOPrey5's Avatar
BirdOPrey5 BirdOPrey5 is offline
Senior Member
 
Join Date: Jun 2008
Location: New York
Posts: 10,610
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I found out there is also a strip_tags() php function that will remove HTML taga, don't need to worry about str_ireplace().
Reply With Quote
  #6  
Old 04-09-2012, 05:46 PM
Morrus Morrus is offline
 
Join Date: Jan 2002
Posts: 494
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by BirdOPrey5 View Post
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!
Reply With Quote
  #7  
Old 04-09-2012, 10:54 PM
BirdOPrey5's Avatar
BirdOPrey5 BirdOPrey5 is offline
Senior Member
 
Join Date: Jun 2008
Location: New York
Posts: 10,610
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
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 01:08 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.04210 seconds
  • Memory Usage 2,224KB
  • 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
  • (4)bbcode_code
  • (1)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (7)post_thanks_box
  • (7)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (7)post_thanks_postbit_info
  • (7)postbit
  • (7)postbit_onlinestatus
  • (7)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
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete