Current time: 11-22-2008, 09:40 AM Hello There, Guest! (LoginRegister)


Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Creating Custom MyCode
09-06-2006, 12:08 AM (This post was last modified: 09-06-2006 12:09 AM by Justin S..)
Post: #1
Creating Custom MyCode
Creating Custom MyCode is quite easy once you understand how it works. Here's a quick overview on how to make Custom MyCode:

First, go to your Admin CP and then to the Message Filters, Custom MyCode, and to Add MyCode.
  • MyCode title
    • That's just the name of the MyCode, fairly simple.
  • MyCode description
    • A basic description of what the MyCode is for; what it does.
  • Regular expression
    • This gets a bit more complicated. On the page, we are given this example:

      Code:
      \[b\](.*?)\[/b\]

      You need to have the \ before the [ and ] so it will work properly. If you imagine it without the \ it looks very basic:

      Code:
      [b](.*?)[/b]

      Of course, you will still need the \ back in there for it to work properly without errors, but you can add those back later before you submit it.
    • I believe (I'm not an expert on this, but it's worked for me so far) that you put the (.*?) each time you want a variable - something the user fills in when using the MyCode. So, for instance, we could have this:

      Code:
      \[a\ href=(.*?) title=(.*?)\](.*?)\[/a\]

      Which would be essentially just like the links in HTML. Now, let's look at the next option:
  • Replacement
    • This is what you want the MyCode to be once the user enters it in. So, for our previous example of the links, you would enter in this:

      <a href="$1" title="$2">$3</a>
    • Basically, all you do is for each (.*?) you put in previously, you put in an incremented variable (such as $1, $2, and $3). It's actually quite simple to understand once you get the hang of it!
  • Activate MyCode
    • This lets you turn it off without deleting it.

Note: If a user is to, for instance, not enter the title in the example above, the MyCode will not work - so if you would want something where users do not have to enter said details, then you should create multiple versions of the same thing, with/without the options.

[Image: signature.png]
Justin S. / MyBB Wiki Lead / belloman.rctgo.net / forums.rctgo.net / rctgo.net
Visit this user's website Find all posts by this user
Quote this message in a reply
09-06-2006, 01:19 AM
Post: #2
RE: Creating Custom MyCode
Googling for "php perl compatible regular expressions" should provide lots of info, and various tutorials. The PHP manual also has a syntax list.

A quick explanation, which should help making future BBCode additions make more sense:
  • A period means "any character". A star means "zero or more", so altogether it means "zero or more of any character".
  • A question mark means "zero or one". In the example, you'd only want to look for the pattern looking for the (X)HTML title attribute to occur only once, or not at all.
  • Parenthesis assigns whatever matches that pattern to a variable.
  • Square brackets have special meaning, so they must be escaped with an escape character, a backslash. The same applies if you want to look for a literal star, period, question mark, etc.
Find all posts by this user
Quote this message in a reply
09-06-2006, 01:22 AM
Post: #3
RE: Creating Custom MyCode
sunspark Wrote:Googling for "php perl compatible regular expressions" should provide lots of info, and various tutorials. The PHP manual also has a syntax list.

A quick explanation, which should help making future BBCode additions make more sense:
  • A period means "any character". A star means "zero or more", so altogether it means "zero or more of any character".
  • A question mark means "zero or one". In the example, you'd only want to look for the pattern looking for the (X)HTML title attribute to occur only once, or not at all.
  • Parenthesis assigns whatever matches that pattern to a variable.
  • Square brackets have special meaning, so they must be escaped with an escape character, a backslash. The same applies if you want to look for a literal star, period, question mark, etc.
Thanks for pointing that out Smile Like I said, I'm just basing this on experience from my use with it in 1.2's testing days, so I tried to make it as basic as possible, without too much "technical" stuff Wink

[Image: signature.png]
Justin S. / MyBB Wiki Lead / belloman.rctgo.net / forums.rctgo.net / rctgo.net
Visit this user's website Find all posts by this user
Quote this message in a reply
09-06-2006, 01:43 AM
Post: #4
RE: Creating Custom MyCode
I saw the system during the beta, but didn't no how it worked thanks for clearing it up for me! Toungue

[Image: sig.png]
Visit this user's website Find all posts by this user
Quote this message in a reply
09-06-2006, 11:42 AM
Post: #5
RE: Creating Custom MyCode
can you give an example to add mycode which play media in windowmediaplayer?
Find all posts by this user
Quote this message in a reply
09-06-2006, 12:27 PM
Post: #6
RE: Creating Custom MyCode
Try this :
Code:
\[media\ filename=(.*?)\](.*?)[/media\]
and

<object width="320" height="290"
classid="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95"
id="mediaplayer1">
<param name="Filename" value="$1">
<param name="AutoStart" value="True">
<param name="ShowControls" value="True">
<param name="ShowStatusBar" value="False">
<param name="ShowDisplay" value="False">
<param name="AutoRewind" value="True">
<embed
type="application/x-mplayer2"
pluginspage="http://www.microsoft.com/Windows/Downloads/Contents/MediaPlayer/"
width="320" height="290" src="$2"
filename="$1" autostart="True"
showcontrols="True" showstatusbar="False"
showdisplay="False" autorewind="True">
</embed>
</object>

(sry for no code[code and php not show $1,$2 vars])

Example use:

[media filename=test.avi]http://example.com/movies/test.avi[/media]

I'm not tested it .
(from http://www.adobe.com/cfusion/knowledgeba...=tn_15777)
Find all posts by this user
Quote this message in a reply
09-06-2006, 12:56 PM (This post was last modified: 09-06-2006 12:56 PM by asmilewyt.)
Post: #7
RE: Creating Custom MyCode
hello,my forum before uprgrade to 1.2 use the code [wmp]link[/wmp] show window media player for mp3.video and [flash]link[/flash] for flash file
can you tell me how to recreate them in mycode admin
instruct every steps please,i'm just a newbie
thanks everyone....mybb best forum and free!
Find all posts by this user
Quote this message in a reply
09-06-2006, 02:12 PM
Post: #8
RE: Creating Custom MyCode
asmilewyt Wrote:hello,my forum before uprgrade to 1.2 use the code [wmp]link[/wmp] show window media player for mp3.video and [flash]link[/flash] for flash file
can you tell me how to recreate them in mycode admin
instruct every steps please,i'm just a newbie
thanks everyone....mybb best forum and free!
Check this:

WMP Tag
MyCode Title
WindowsMediaPlayer (you can use other)
MyCode Desc
WMP player (you can use other)
Regular Expression
Code:
\[wmp\](.*?)\[/wmp\]
Replacement
<OBJECT id="VIDEO" width="320" height="240"
style="position:absolute; left:0;top:0;"
CLASSID="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6"
type="application/x-oleobject">

<PARAM NAME="URL" VALUE="$1">
<PARAM NAME="SendPlayStateChangeEvents" VALUE="True">
<PARAM NAME="AutoStart" VALUE="True">
<PARAM name="uiMode" value="full">
<PARAM name="PlayCount" value="1">
</OBJECT>


Flash Tag

MyCode Title
Flash BBCode(you can use other)
MyCode Desc
Opening a flash file(you can use other)
Regular Expression
Code:
\[flash\](.*?)\[/flash\]
Replacement
<object width="320" height="240">
<param name="movie" value="$1">
<embed src="$1" width="320" height="240">
</embed>
</object>
Find all posts by this user
Quote this message in a reply
09-06-2006, 02:21 PM
Post: #9
RE: Creating Custom MyCode
thanks a lot.you're so kind!!
Find all posts by this user
Quote this message in a reply
09-06-2006, 02:29 PM
Post: #10
RE: Creating Custom MyCode
oh it doesn't work.just show the blank in the post
Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump: