Search Highlight destroys preg_replace
#1
Hi,
I'm designing a plugin which I use preg_replace in it. For Example:

	$message =preg_replace('#\[plugintag\](.*?)\[/plugintag\]#s',"<div align=\"center\">{$text}</div>", $message);	
This works perfectly, but when a search highlight is given in showthread.php and the highlight word is like a word (or is like the tags) between the plugin tags (or is like the tags), it will be highlighted and the tags will be destroyed and won't functioning!(Like the attached image)


Attached Files Thumbnail(s)
   
Reply
#2
what hook are you using?
Lost interest, sold my sites, will browse here once in a while. It's been fun.
Reply
#3
(2012-10-04, 06:25 PM)pavemen Wrote: what hook are you using?

parse_message
Reply
#4
This user has been denied support. This user has been denied support.
Try parse_message_start instead - although I guess that might mess with HTML.

parse_message_start is called before html/mycodes/highlights are parsed; parse_message afterwards.

Ugly solution, but you could replace your tags with a random string in parse_message_start and replace the random string with whatever in parse_message. Can't highlight a random string (if it's unique for that post).

A hook for parse_mycode would probably work best but it does not exist.
Reply
#5
what you are doing is simply an custom mycode, so you dont need a plugin for that. are you wanting to do something more complex later once the basics are worked out?
Lost interest, sold my sites, will browse here once in a while. It's been fun.
Reply
#6
(2012-10-04, 09:33 PM)pavemen Wrote: what you are doing is simply an custom mycode, so you dont need a plugin for that. are you wanting to do something more complex later once the basics are worked out?
Yes, This is an example! I want to use a (Really) more complex tag!Huh


(2012-10-04, 09:22 PM)frostschutz Wrote: Try parse_message_start instead - although I guess that might mess with HTML.

parse_message_start is called before html/mycodes/highlights are parsed; parse_message afterwards.

Ugly solution, but you could replace your tags with a random string in parse_message_start and replace the random string with whatever in parse_message. Can't highlight a random string (if it's unique for that post).

A hook for parse_mycode would probably work best but it does not exist.
Thank you but it will show the text between my tags as html codes!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)