vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3.0 Full Releases (https://vborg.vbsupport.ru/forumdisplay.php?f=33)
-   -   How to remove HTML tags from thread preview (good for HTML-enabled forums especially) (https://vborg.vbsupport.ru/showthread.php?t=61372)

Gary King 02-09-2004 10:00 PM

How to remove HTML tags from thread preview (good for HTML-enabled forums especially)
 
Don't you just hate it when thread previews show HTMl tags even though browsers don't interprete those tags in popup menus? Well then this hack is just right for you! ;)

This hack will remove all HTML tags such as <b>, <i>, <strong> and even closing tags like </b>, </i>, and </strong> so that they don't show up in the thread preview. It's genius they say! :p

Anyways here we go:

open up forumdisplay.php and find
PHP Code:

                eval('$threadbit .= "' fetch_template('threadbit') . '";'); 

Above, add

PHP Code:

                $thread[preview] = eregi_replace('(")','',strip_tags(unhtmlspecialchars($thread[preview]))); // solution #2 

If the above code doesn't show some thread previews properly, try the one below:
PHP Code:


                $thread
[preview] = eregi_replace('(&[a-z]+;|&lt;[a-zA-Z]+&gt;[a-zA-Z]+&lt;/[a-zA-Z]+&gt;)','',strip_tags($thread[preview])); 

All done :)

Andreas 02-10-2004 12:01 AM

Nice, but why not just

PHP Code:

$thread[preview] = strip_tags($thread[preview]); 

?

Gary King 02-10-2004 12:18 AM

Fixed :) (You needed unhtmlspecialchars()) first.

Andreas 02-10-2004 12:25 AM

Hmm ... now this code might produce invalid XHTML (thinking of quotes and ampersand).

Gary King 02-10-2004 12:27 AM

*testing* :) I'll post back with a full solution when I have one, should take a few minutes only heh :D

Andreas 02-10-2004 12:40 AM

PHP Code:

 $thread[preview] = htmlspecialchars(strip_tags(unhtmlspecialchars($thread[preview]))); 

might do the trick ;)

Gary King 02-10-2004 12:46 AM

Foolproof solution attached ;)

CarlitoBrigante 02-10-2004 09:01 AM

Quote:

Originally Posted by Gary W
Foolproof solution attached ;)

Great it work! Should be enabled by default in next vb builds, can't someone contact the development staff?

Gary King 02-10-2004 11:20 AM

You could submit it as a bug and link to this thread if you want :p

CarlitoBrigante 02-10-2004 12:48 PM

Quote:

Originally Posted by Gary W
You could submit it as a bug and link to this thread if you want :p

Will do!

gmarik 02-11-2004 06:21 PM

What is this about, can't get the idaea...

cybermomcafe 03-23-2004 12:51 PM

Is there any way to make this stop what is happening in the attached image...

What I was doing was using a replacement variable, {ebaylist} or {paypaldonate} for example to insert a preformatted paypal cart form or ebay listing into a post...

I don't care so much about the mouseover thread preview, just the "> that shows up by the thread title...

Thanks in advance!

Here's a link to the forum with the post I'm talking about... http://www.cybermomcafe.com/vb/forumdisplay.php?f=3

Gary King 03-23-2004 01:34 PM

Quote:

Originally Posted by cybermomcafe
Is there any way to make this stop what is happening in the attached image...

What I was doing was using a replacement variable, {ebaylist} or {paypaldonate} for example to insert a preformatted paypal cart form or ebay listing into a post...

I don't care so much about the mouseover thread preview, just the "> that shows up by the thread title...

Thanks in advance!

Here's a link to the forum with the post I'm talking about... http://www.cybermomcafe.com/vb/forumdisplay.php?f=3

I copied the code used in your post, and now there is nothing in the thread preview for me (which is a good thing, since you'd rather have nothing than broken stuff.)

Did you use the first replacement code I suggested in my instructions?

cybermomcafe 03-23-2004 02:18 PM

Yeah, I tried both of them...

If I put the code straight into the post (enabling HTML on the forum, which I am trying to avoid) it doesn't add the "> above the thread title, but if I do it as a replacement variable it does...?

I turned on guest posting in that forum also... ;)

I spose I could just turn on HTML LOL

I was using {ebaylisting} to be replaced with:

Code:

<script language="JavaScript" src="http://lapi.ebay.com/ws/eBayISAPI.dll?EKServer&ai=avm%7dz%7em.%26%28%26&bdrcolor=FFCC00&cid=0&endcolor=FF0000&endtime=y&fntcolor=000000&fs=0&hdrcolor=FFFFCC&img=y&num=25&numbid=y&popup=n&prvd=0&query=baby+clothing&siteid=0&sort=MetaEndSort&sortby=endtime&sortdir=asc&srchdesc=n&tlecolor=FFCE63&track=&width=570"></script>
Thanks for taking a look!

Intex 06-12-2004 12:44 PM

Nice work Gary_King. I've installed and it works apart from one thing. I have another hack that replaces <br> with <br />. How would I also exclude <br /> as well?

Gary King 06-12-2004 01:28 PM

Quote:

Originally Posted by Intex
Nice work Gary_King. I've installed and it works apart from one thing. I have another hack that replaces <br> with <br />. How would I also exclude <br /> as well?

You should remove that other hack, then, then see what the results are.

Intex 06-12-2004 01:30 PM

That particular hack is pretty important to me and needs to stay. I want to use this hack as well, so if there is a way to specifically exclude <br /> that would be great, otherwise I'll have to remove this one- which I don't really want to do.


All times are GMT. The time now is 03:44 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.01107 seconds
  • Memory Usage 1,762KB
  • 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
  • (1)bbcode_code_printable
  • (5)bbcode_php_printable
  • (4)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (17)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