Closed Thread Icon

Topic awaiting preservation: Help writing some phpBB BBcode please? Pages that link to <a href="https://ozoneasylum.com/backlink?for=25687" title="Pages that link to Topic awaiting preservation: Help writing some phpBB BBcode please?" rel="nofollow" >Topic awaiting preservation: Help writing some phpBB BBcode please?\

 
Author Thread
CPrompt
Maniac (V) Inmate

From: there...no..there.....
Insane since: May 2001

posted posted 05-05-2005 22:59

I am *attempting* to make a bbcode mode for a forum but I'm getting a little lost in this whole template thing.

Let me first tell you what I am *attempting* to do.

Add a button to the posting page for the user that will format a link to reference to the Wiki. The way the wiki is setup is that it has the base url:
( i.e. http://www.mywebsite.com/wiki ) and then the topics are referenced as ?id=mytopic

So, for the bbcode that I need if someone where to do this: [wiki]mytopic[/wiki] it would display only the topic name and be a link to the wiki with that topic. kind of like <a href="www.mywebsite.com/wiki?id=mytopic">mytopic</a>

Make sense so far?

Now..if the topic the person started has white spaces like My Topic then it is replaced by _'s so it becomes ?id=my_topic
Not a big deal, i can just do this:

code:
$string = "This is a  test";
$specChar = "_";

//replace whitespace with "_" and strip additional whitespaces
$string2 = preg_replace('/\s\s+/', ' ', $string);
$string2 = str_replace(" ", $specChar,$string);

print "<a href=\"http://www.mywebsite/wiki/index.php?id=wiki:$string2\">$string</a>";



will out put This is a test but the link will be this_is_a_test.

So..........now that is out of the way. Can someone please help me integrate this into phpBB's BBcode? Like I said........I am getting pretty lost with it's template thing. Tried to use the url tag as a model and failed.

Thanks in advance!

Later,

C:\

reisio
Paranoid (IV) Inmate

From: Florida
Insane since: Mar 2005

posted posted 05-05-2005 23:50

Meh, doing anything with the mess that is phpBB code is seriously probably at the bottom of my 'Things I hate to do' list...after eating dirt and listening to the Backstreet Boys.

Anyways...

It'd probably be simpler to base it off the img bbcode, but do see if one of the two 'Custom BBCodes' MODs at this site can do what you want first: http://www.fubonis.com/mods.html (no idea, but I'd try just about anything before screwing with phpBB code myself)

butcher
Paranoid (IV) Inmate

From: New Jersey, USA
Insane since: Oct 2000

posted posted 05-06-2005 01:19

CPrompt

Give me a bit and I'll get back to you. Running out the door at the moment.

-Butcher-

(Edited by butcher on 05-06-2005 01:20)

butcher
Paranoid (IV) Inmate

From: New Jersey, USA
Insane since: Oct 2000

posted posted 05-06-2005 03:24

Okay, let's give this a try.

In the bbcode.tpl file (should be /templates/subSilver/bbcode.tpl) you need to add this line.

code:
<!-- BEGIN wiki --><a href="http://www.mywebsite/wiki/index.php?id=wiki:{QUERY}" target="_blank">{STRING}</a><!-- END wiki -->



Then you need to add code to bbcode.php (should be /includes/bbcode.php) in 3 different places.

In the function prepare_bbcode_template() you should add these lines.

code:
$bbcode_tpl['wiki'] = '\'' . $bbcode_tpl['wiki'] . '\'';
$bbcode_tpl['wiki'] = str_replace('{STRING}', "' . str_replace('\\\"', '\"', '\\1') . '", $bbcode_tpl['wiki']);
$bbcode_tpl['wiki'] = str_replace('{QUERY}', "' . str_replace(' ', '_', '\\1') . '", $bbcode_tpl['wiki']);
$bbcode_tpl['wiki'] = str_replace('{QUERY}', "' . urlencode(str_replace('\\\"', '\"', '\\1')) . '", $bbcode_tpl['wiki']);



In the function bbencode_second_pass() you need to add in 2 places.

Drop this one in somewhere under the code with this comment:

// and for italicizing text.

code:
// for clearing extra spaces in a [wiki] text.
if (preg_match('/\[wiki\](.*?)\[\/wiki\]/si', $text, $matches))
{
$text = str_replace($matches[0], '{HOLDER}', $text);
$new_string = preg_replace('/\s\s+/', ' ', $matches[0]);
$text = str_replace('{HOLDER}', $new_string, $text);
}



Then drop this in somewhere under the code with this comment:

// user@domain.tld code..

code:
// [wiki]http://www.mywebsite/wiki/index.php?id=wiki:[/wiki] code..
$patterns[] = "#\[wiki\](.*?)\[/wiki\]#ise";
$replacements[] = $bbcode_tpl['wiki'];



but above this bit of code:

code:
$text = preg_replace($patterns, $replacements, $text);

// Remove our padding from the string..
$text = substr($text, 1);

return $text;



I hope this helps.

-Butcher-

CPrompt
Maniac (V) Inmate

From: there...no..there.....
Insane since: May 2001

posted posted 05-06-2005 04:40

holy shit butcher! wow! Thanks a bunch for that. I'm gonna give this a shot over the weekend and see how it goes.

I did install a MOD so that I could add some bbcode. According to the mod site, you had to have it in order to use custom bbcode. So, hopefully it will not get in the way of doing this.

thanks again man! that's 2 i owe you if this works

Later,

C:\

CPrompt
Maniac (V) Inmate

From: there...no..there.....
Insane since: May 2001

posted posted 05-06-2005 17:23

worked like a charm Butcher!! Now I just have to add the button and the entry in the phpBB FAQ. Thanks!!! You've been a great help on the past two things I couldn't figure out. Much appreciated!

Later,

C:\

butcher
Paranoid (IV) Inmate

From: New Jersey, USA
Insane since: Oct 2000

posted posted 05-06-2005 22:07

No sweat.

Just glad I could help.

-Butcher-

CPrompt
Maniac (V) Inmate

From: there...no..there.....
Insane since: May 2001

posted posted 05-06-2005 22:39

yep. that you did. got the button up and all the FAQ stuff and it's off and running.

thanks again!

Later,

C:\

« BackwardsOnwards »

Show Forum Drop Down Menu