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

Replacing old custom YOUTUBE BBcode in posts

Discussion in 'XenForo Questions and Support' started by Ingenious, Feb 15, 2012.

  1. Ingenious

    Ingenious Well-Known Member

    In my imported forum, all YouTube videos are embedded in posts using some custom BBcode, because otherwise vB just displayed a link to the video and not embed the actual video. So my forum posts are full of:

    [YOUTUBE]videocode[/YOUTUBE]

    Is there an easy way I can do a search and replace on these as follows:

    find [YOUTUBE]$string[/YOUTUBE]
    replace with

    Code:
    http://www.youtube.com/watch?v=$string
    I'm sure I read somewhere you can do a search and replace but I cannot for the life of me find this now. I can't see any options either in XenForo admin or vB admin to run a search and replace query like this.

    Any ideas please? :)
     
    brucey likes this.
  2. Brogan

    Brogan XenForo Moderator Staff Member

    Take a backup first.

    Code:
    UPDATE xf_post SET message = REPLACE(message, '[youtube]', '[media=youtube]');
    UPDATE xf_post SET message = REPLACE(message, '[/youtube]', '[/media]');
    That will embed all videos, assuming just the video ID is between the existing youtube tags.
     
    Phases, brucey, Mendo and 2 others like this.
  3. Ingenious

    Ingenious Well-Known Member

    Brilliant - just tried that and it works 100% :) Many thanks!
     
  4. turkyalawlqy

    turkyalawlqy Active Member

    I also had the same problem
    [YOUTUBE;$string]$string[/YOUTUBE]
    Code:
    http://www.youtube.com/watch?v=$string
    Can I replace all the orders one?
     
  5. Brogan

    Brogan XenForo Moderator Staff Member

  6. EgyKit

    EgyKit Member

    This was really helpful :), there was some old custom vbulletin youtube tags didn't change using this add-on

    http://xenforo.com/community/threads/post-content-find-replace.6548/

    This was fast, accurate and save, but always remember to do backup before you play with the database!
     
    Jake Bunce likes this.

Share This Page