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

Parse URLs in Post text after DB Update

Discussion in 'XenForo Questions and Support' started by Sadik B, May 6, 2012.

  1. Sadik B

    Sadik B Well-Known Member

    So I migrated a phpBB forum to XF. There were all sorts of <a href> links in posts from which I successfully extracted the link within href attributes using Kier's Find and Replace addon which updated the DB.

    So now the posts contain only links like this

    http:// somesite.com (displayed as text, have put space here to demonstrate)

    However the problem is that now all of these links are just being displayed as text. Meaning they are not parsed and surrounded by the tags. Also many of the links are youtube videos, which I thought would get auto-embedded since I have auto-embed enabled. However the links are just sitting there as text. If I click on "Edit" on a post with a link and save, the link is recognised and converted to url, but obviously I can't manually edit thousands of such posts.

    I rebuilt the thread and search caches thinking some thing would trigger the post parser, but no joy... What am I doing wrong? Any suggestions?

    Thanks...
     
  2. Floris

    Floris Guest

    tip on xenforo to display something in a post without parsing it.
    [plain]http://google.com[/plain]
     
    Sadik B likes this.
  3. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Auto parsing / embedding happens on save. For your purposes you should use the find / replace tool to convert those plain URLs into hyperlinks and media embeds. Hyperlinks should be surrounded by URL tags. Media embeds should use this format:

    Code:
    [media=youtube]IDHERE[/media]
    
     
    Sadik B likes this.
  4. Sadik B

    Sadik B Well-Known Member

    Hmmm, I get your point but there is no way to know which url in the post would be hyperlink and which would be a media embed (youtube or similar). I can probably though write a few regex for each url case and run the find replace tool.

    I am curious though. If I change a BBCode definition, how does XF handle that? For instance what if I added a SCRIBD embed bbcode and then later wanted to change the embed code. Are you saying that old posts will not update for the changed BBCode?
     
  5. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Sadik B likes this.
  6. Sadik B

    Sadik B Well-Known Member

    Thanks Jake... I was however wondering about the changing BBCode thing. It's just an academic question since I am not doing any such thing. But what if someone defined a BBCode and later changed it.
     
  7. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Then you can use the find / replace tool to update previous media tags. Or use a query:

    Code:
    UPDATE xf_post
    SET message = REPLACE(message, '[media=oldid]', '[media=newid]')
    
     
  8. Sadik B

    Sadik B Well-Known Member

    Ah.. ha :)

    Thanks Jake!
     
  9. Floris

    Floris Guest

    If they edit their post, it will be parsed anyway, regardless of full url or bbcode
     

Share This Page