Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[F] custom mycode question (wiki type links)
#1
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?
#2
What are the regular expressions and replace codes you are using?
Dennis Tsang
Former MyBB Team Member
Web: http://dennistt.net
#3
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.
#4
The problem with your REGEX is that it requires the Encyclopedia Dramatica to be executed first.
#5
Right, so.....  How do I make that happen?

The problem I know, the solution has me at a loss. I suck at regex Smile
#6
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.
#7
Oh? It's that simple? I gotta go try that....

Nope, didn't work. Same problem. Sad
#8
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?
#9
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.
Dennis Tsang
Former MyBB Team Member
Web: http://dennistt.net
#10
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.


Forum Jump:


Users browsing this thread: 1 Guest(s)