MyBB Community Forums

Full Version: Tutorial - Creating MyCode
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3
Ok, just finished this up. I copied it over from my original post. I will be creating more exclusive tutorials on my forum during this week.. I'll add the more frequent requests here on MyBB.

Let's begin...

MyCodes are pretty simple. All they do is replace an HTML tag.

For the sake of the tutorial, let's create a custom YouTube MyCode, since it seems to be of a lot of interest. It will also give you an understanding on how to create your own MyCodes for other video sites and creating code from custom HTML.

This will be very easy for you to understand and it will be step by step.

Step 1
[Image: step1.png]

Step 2
[Image: step2.png]

Step 3
[Image: step3.png]

Step 4
[Image: step4.png]

Step 5
[Image: step5.png]

Step 6
[Image: step6.png]

Go ahead now and paste the embed code inside of the box shown below.

Step 7
[Image: step7.png]

Step 8
[Image: step8.png]

Step 9
[Image: step9.png]

Step 10
[Image: step10.png]

Step 11
[Image: step11.png]

Step 12
[Image: step12.png]


Things to remember:
When testing, be aware that things don't display 100% correctly in all cases. If you're confident your code is correct, and you're test result is funky, try saving the code, and testing the function via a new post in your forum.

If you want to create a new MyCode it's pretty simple. Do the same routine as you did here. For example, if you want to create a Google video MyCode it will be a similar experience. Note that it doesn't work for all videos. You'll understand why once you've tried it on some things.

If you wanted to create a code that will make red text, for example, it's pretty easy. Your replacement can be something like <font color="#FF0000">$1</font> and you'd then just use \[redtext\](.*?)\[/redtext\] for the regular expression.. that way if a user entered [redtext]This is red text[/redtext] it'd come out as This is red text. The sky's the limit. Have fun.
this is by far the best available tutorial for making a mycode.
Thanks a lot
You're welcome Smile Just wanted to clear things up since I know this is often requested and often misunderstood.. this should be a no-brainer for people hoping to create their own stuff.

If you run into any trouble let me know.
I understand the concept of Mycode, and I did exactly what you said in this tutorial, but it gave me [youtube]ZEK0t5_JRlY[/youtube] in both the html result and actual results field.
You must have gotten something mixed up somewhere.. If you followed correctly there's really no way to go wrong about this..

What is your "Regular Expression" you're using?

And what is you're "Replacement" that you're using?

Also, what did you try typing into the test field?
Regular expression:
\[youtube\](.*?)\[/youtube\]

Replacement:
<object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/$1&hl=en&fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/$1&hl=en&fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed></object>

I tried typing [youtube]ZEK0t5_JRlY[/youtube]
I just used your video ID# on my forum with no issue..

Sometimes what happens is that the "Test" function doesn't display things properly.. I will add a note about that into my post..

Try to save your MyCode and then attempt to test it in a new thread.. Just hit Preview and you should know then..
Nope. I put in "It should be working now:
[youtube]vEgCsYJVXxs[/youtube]" for my post, and it gave me exactly that in the post.
Mind if I have a look into your ACP?.. I'll find out what's doing this.

Just create a test admin acct and PM the details..
I'm sorry. I just not comfortable with that.
Pages: 1 2 3