PDA

View Full Version : find and replace in a varible?


nitra1000
07-10-2011, 12:26 AM
I'm looking for a way to search a stored varible (a post for example) for instances of a links and add a rel varible to it, in php...

So....

<a href="someurl"

To

<a href="someurl" rel="somerel"

LifesGreatestGift
07-10-2011, 02:20 AM
so specific URLs or all URLs?

nitra1000
07-10-2011, 03:21 PM
All urls. Thanks, john

Also important to note the link might have a title or already have a rel attribute

LifesGreatestGift
07-10-2011, 04:36 PM
New plugin
Product: vBulletin
Title: 0 - rel="#" to links
Hook: postbit_display_complete
$this->post['message'] = str_replace('target=', 'rel="somerel" target=', $this->post['message']);
Active: yes

Change somerel to whatever you want.

nitra1000
07-12-2011, 08:31 PM
Thanks alot for that, really helped (have added a comment to the code crediting this post)