View Full Version : How to remove HTML tags from thread preview (good for HTML-enabled forums especially)
Gary King
02-09-2004, 10:00 PM
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 eval('$threadbit .= "' . fetch_template('threadbit') . '";');
Above, add
$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:
$thread[preview] = eregi_replace('(&[a-z]+;|<[a-zA-Z]+>[a-zA-Z]+</[a-zA-Z]+>)','',strip_tags($thread[preview]));
All done :)
Andreas
02-10-2004, 12:01 AM
Nice, but why not just
$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
$thread[preview] = htmlspecialchars(strip_tags(unhtmlspecialchars($th read[preview])));
might do the trick ;)
Gary King
02-10-2004, 12:46 AM
Foolproof solution attached ;)
CarlitoBrigante
02-10-2004, 09:01 AM
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
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
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:
<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
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.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2024, vBulletin Solutions Inc.