MyBB Community Forums

Full Version: [F] custom mycode question (wiki type links)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Ok, so I'm trying to setup wiki tags on my forum. As long as I just have one, for linking to Wikipedia, it's no problem.

[[Wikipedia]]
Shows as: Wikipedia

However, if I try to have a similiar code to link to another Wiki, like Encyclopedia Dramatica, for example, that's tougher.

[[ed:Wikipedia]]
Should show as Wikipedia

Instead, it shows as Wikipedia

I think you get the point now. I knew this might be a problem (hoped it wouldn't be, lol). Is there any way around it or am I just SOL?
What are the regular expressions and replace codes you are using?
Sorry, it took a couple days to get back to you.

For Wikipedia:
 Expression:  
\[\[(.*?)\]\]

Replace:
<a target="_blank" href="http://en.wikipedia.org/wiki/$1" title="Wikipedia:  $1">$1</a>

And for ED:
 Expression:  
\[\[ed:(.*?)\]\]

Replace:
<a target="_blank" href="http://www.encyclopediadramatica.com/index.php/$1" title="Encyclopedia Dramatica:  $1">$1</a>

Now, I didn't really think this would work and I expected the problem I got, but now I'm wondering just how to write it correctly so that I *can* do what I'm trying to do.
The problem with your REGEX is that it requires the Encyclopedia Dramatica to be executed first.
Right, so.....  How do I make that happen?

The problem I know, the solution has me at a loss. I suck at regex Smile
You should be able to get around this by adding the ed: tag first then the other tag. Since it would select the ed tag first then.
Oh? It's that simple? I gotta go try that....

Nope, didn't work. Same problem. Sad
Ok, I'm gonna bump this back up one more time before giving up and accepting that it won't work. Does anybody else have any ideas?
Can you give this modification a shot:
In inc/class_datacache.php find:
		$query = $db->simple_select(TABLE_PREFIX."mycode", "regex, replacement", "active='yes'");
Replace with:
		$query = $db->simple_select(TABLE_PREFIX."mycode", "regex, replacement", "active='yes'", array('order_by' => 'LENGTH(regex)', 'order_dir' => 'DESC'));

Rebuild the mycode cache, and try it again.
Looking at that, I imagine it would work, but I'm not gonna go changing files to get a simple bbcode to work like I want it to. I can accept that it won't work with the current MyBB code. I'll just use [ed][/ed] instead.

I appreciate the help and I've bookmarked this so I can come back to it if I change my mind, but really, diving into the code just to make a bbcode work is overkill. I'm sure it will work, but it's more than I was looking for. Thank you anyway, Dennis.
Pages: 1 2