• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Need some help with media bbcode

Ray

Active member
#1
Hello, everyone!

I would like to add a custom bbcode. When entering the following bbcode:

[video] video id [/video]

I should see the video player plus a message "ID: video id" under the player.

I know I have to edit the Base.php file, but don't really know what code I should use.

i.e.

PHP:
<embed src="http://----.com/?v={$id}"></embed>
<br />
<b>ID: {$id}</b>
As you can see, the first {$id} displays the player and the second {$id} outputs the ID in plain text.

See screenshot

thanks
 

Attachments

Jake Bunce

XenForo moderator
Staff member
#2
You can add to the existing [media] BB code:

Admin CP -> Home -> BB Code Media Sites

Look at the existing media sites for code examples. It's fairly straight forward. Once you add your media site then you can use code like this in your post:

[media=youtube]zA_zTJpkoh8[/media]

Or you can click the Screen shot 2010-11-05 at 9.19.04 AM.png icon in the editor and paste the full URL.

edit - here are some media sites people have added:

http://xenforo.com/community/threads/add-more-video-sites-bb-code-media.7608/
 

Ray

Active member
#3
That would work for new posts, but will take some time to edit 50k posts to reflect the new bbcode.

The existing bbcode is [video] [/video]

Do you know how I could update all the existing posts at once?

Thanks
 

Jake Bunce

XenForo moderator
Staff member
#4
A string replacement query might work for your purposes:

UPDATE xf_post
SET message = REPLACE(message, '[video]', '[media=youtube]')

UPDATE xf_post
SET message = REPLACE(message, '[/video]', '[/media]')

Backup first.