MyBB Community Forums
[F] custom mycode question (wiki type links) - Printable Version

+- MyBB Community Forums (https://community.mybb.com)
+-- Forum: Community Archive (https://community.mybb.com/forum-106.html)
+--- Forum: Archived Forums (https://community.mybb.com/forum-143.html)
+---- Forum: Archived Development and Support (https://community.mybb.com/forum-155.html)
+----- Forum: Archived Bug Reports (https://community.mybb.com/forum-74.html)
+------ Forum: MyBB 1.2.2 (https://community.mybb.com/forum-49.html)
+------ Thread: [F] custom mycode question (wiki type links) (/thread-14625.html)

Pages: 1 2


[F] custom mycode question (wiki type links) - Galen - 2006-12-15

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?


RE: custom mycode question (wiki type links) - Dennis Tsang - 2006-12-16

What are the regular expressions and replace codes you are using?


RE: custom mycode question (wiki type links) - Galen - 2006-12-18

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.


RE: custom mycode question (wiki type links) - laie_techie - 2006-12-18

The problem with your REGEX is that it requires the Encyclopedia Dramatica to be executed first.


RE: custom mycode question (wiki type links) - Galen - 2006-12-18

Right, so.....  How do I make that happen?

The problem I know, the solution has me at a loss. I suck at regex Smile


RE: custom mycode question (wiki type links) - Martin M. - 2006-12-18

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.


RE: custom mycode question (wiki type links) - Galen - 2006-12-18

Oh? It's that simple? I gotta go try that....

Nope, didn't work. Same problem. Sad


RE: custom mycode question (wiki type links) - Galen - 2006-12-20

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?


RE: custom mycode question (wiki type links) - Dennis Tsang - 2006-12-20

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.


RE: custom mycode question (wiki type links) - Galen - 2006-12-20

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.