Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

slooksterPSV

macrumors 68040
Original poster
Apr 17, 2004
3,546
309
Nowheresville
Hey I'm just curious on how this works. I was reading on it in the FAQ. You guys have used the [ coding ] things. How do you get something like this working on a website?
I think this shows:
Code:
[img][/img]

I think it would prove useful for some situations not just for Forums.
 
The brackets are specific to vBulletin. This is the code that operates the forum. http://www.vbulletin.com/

From the bottom of the page:

Powered by: vBulletin Version 3.0.0
Copyright ©2000 - 2004, Jelsoft Enterprises Ltd.
Copyright 2002-2004, MacRumors.com​
 
Of course, nothing stopping you emulating what vBulletin does on your own site - you just need to run the text through a process to replace the [ code ] tags with the appropriate HTML.

For example, using PHP

PHP:
print preg_replace("/\[code\](.+)\[\/code\]/Usi", "<pre>\\1</pre>", $text);

(vBulletin adds a bit more than just <pre> but that gives you the general idea, also, that code isn't completely perfect as it'll get confused if the code part contains the tag [ code ])
 
I was just actually coming to post that. You could make a sort of scripted compiler, in the sense that you replace the code with the code that is programmed in, and have it show like vB Bulliten does. I may have to try that.
 
I'm surprised there isn't a script out there that does this conversion. There are a lot of other forum systems that use the exact same set of codes using the square brackets. But then I guess coding it in JS or whatever would be pretty easy....
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.