MyBB Community Forums

Full Version: Force MyCode to ignore URL's? Or is there another solution for word replacement...?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
I want to change words so that they are transformed into a link. Example, nike = nike

MyCode does this for me.

But its making a problem with any links that would contain the word 'nike'. Making the link look like this:

[url]http://www.shoes.com/nike-jordan.html[/url]

So we actually see the BBCode in the post and the link becomes dead other than the word 'nike', which is transformed into the link nike.com.

I hope I'm making sense to you. What I need to do is universally transform words that aren't in links - into links, but don't transform links with the given word. I know that's confusing looking, but hopefully you understand.

Is there some solution here?
Bump. Still wondering about an answer for this. Basically I need to transform things within only the post body, but not affect any existing links within the body.
Bump. I'm feeling like I'm not getting enough feedback here. My feelings are hurt. I realize I sometimes ask some tough questions. About 30% of my questions go completely unanswered. Maybe if there exists no such thing, you could at least reply and let it be known it doesn't exist. Thanks Smile
I THINK you're asking for words to be links and that's already standard in the advanced reply area. That little "globe & link" icon will do that for you.

So if you want the word Nike to be a link and not show the url, all you do is this:

[url=http://nike.com]NIKE[/url]

Like this:

NIKE
(2013-10-21, 02:15 PM)Goggalor Wrote: [ -> ]I THINK you're asking for words to be links and that's already standard in the advanced reply area. That little "globe & link" icon will do that for you.

So if you want the word Nike to be a link and not show the url, all you do is this:

[url=http://nike.com]NIKE[/url]

Like this:

NIKE

Sorry if I'm being confusing... I want to do it from backend (or wherever I need to do it) and transform ALL words retroactively and any future. So every past post and future post that have nike, become nike....

It can be done with MyCode, but this completely mangles any links that have the word nike in it.

Example. Someone typed: http://www.shoes.com/nike
Is seen as this in the post: {url}http://www.shoes.com/nike{/url}.

It also ruins the topic directly above the post body in all the replies if the topic has the word nike in it.

It's strange this has never come up before. Wanting to transform words into links in the body only, without affecting other links or other parts of the post.

I suppose it would take a custom plugin?

A picture is worth 500 words I suppose. This screeny is not in edit mode. It's as the post shows.
This just requires the proper regex.

This one works for nike, Nike, NiKe, and any other lowercase/caps combination. It may need adjusted with extra lookaheads and lookbehinds if there are other word boundary characters that you want to ignore, I've only done \ (as \\ since it needs to be escaped) and /, which should disallow file paths and urls from being included, but allow everything else as long as it is a word boundary (\b check)

You can thank Goggalor for pointing me at this thread.

Regex:
(?<![/\\0-9])\b([nN][iI][kK][eE])\b(?![/\\0-9])

Replacement:
[url=http://nike.com]$1[/url]

Enabled:
Set true

Parse Order:
0
Thanks Dylan. I didn't think I had the right answer but I hated seeing this guy's post go ignored for so long. I know how that feels. Smile
(2013-10-22, 08:00 PM)Goggalor Wrote: [ -> ]Thanks Dylan. I didn't think I had the right answer but I hated seeing this guy's post go ignored for so long. I know how that feels. Smile

If I wasn't so busy with college I'd answer more of these questions. I hate not having time.
Can't you set the "i" flag for case-insensitive and not need the [nN] type optional letter comparison?
(2013-10-22, 08:44 PM)pavemen Wrote: [ -> ]Can't you set the "i" flag for case-insensitive and not need the [nN] type optional letter comparison?

Not in MyCode, or at least it didn't work when I tried it. This is because the i flag would go outside the pattern delimiters, and we hard code those.

I'm all for changing this in 1.8/2.0 to be full proper patterns including flags and pattern delimiters. I have a feeling that would be an issue for some people however.
Pages: 1 2