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

XF 1.2 Find/Replace URLs in Posts (Regex/VBSEO)

Discussion in 'Installation, Upgrade, and Import Support' started by DeviateDefiant, Feb 22, 2014.

  1. Morning,

    I'm in the middle of finalising a migration from vBulletin v4.2.2 which was utilising the defunct VBSEO plugin, it also includes a domain migration. I want to utilise Kier's Find & Replace plugin to replace the old internal links.

    I could leave them linking off-site and having the .htaccess rewrite bounce it back, but it's an ugly solution and I'd rather get the job done properly.

    The old VBSEO structure:
    Code:
    http://domain.tld/category-name/00-thread-name.html#post00
    Link example:
    Code:
    http://accordownersclub.co.uk/7th-generation-accord/4621-new-member-2-4-type-s-2.html#post35539
    Xenforo deploy:
    Code:
    http://hondakarma.com/threads/4621/#post-35539
    Migrating the thread name isn't important as I know XF will redirect fine with just a thread ID. The only part I'm not sure on, is when matching a specific post in a thread using an ID, if the post linked isn't on the first page, XF doesn't seem to redirect automatically to the correct page containing that post. Basically just relying on browser's native navigation by HTML "id" attribute.

    Any help appreciated, Regex is not my friend.
     
  2. Bump for visibility.
     
  3. EQnoble

    EQnoble Well-Known Member


    First of all, welcome to the community.

    While regex happens to be a friend of mine there is some work involved in this, I am a bit tired and going to sleep in a few. I probably need more info but if you like I can get back to you with what I need to know if anything tomorrow when I wake up?


    Ant
     
  4. That's greatly appreciated, not a problem at all.
     
  5. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Use this addon:

    http://xenforo.com/community/resources/post-content-find-replace.1549/

    Quick Find: http://accordownersclub.co.uk/

    Regular Expression: #http://accordownersclub\.co\.uk/[a-zA-Z0-9_\-]+/([0-9]+)-[a-zA-Z0-9_\-]+\.html\#post([0-9]+)#siU

    Replacement String: http://hondakarma.com/posts/\2/



    The /posts route in XF redirects to the appropriate page and anchor when given the postid.
     
  6. Thanks for that, I assume that expression will only match URLs that include the post ID anchor on the end, right?

    Working backwards, would the below then cover the thread links themselves? ...and if not, if it's not too much trouble could you fix my attempt? :D

    Code:
    #http://accordownersclub\.co\.uk/[a-zA-Z0-9_\-]+/([0-9]+)-[a-zA-Z0-9_\-]+\.html#siU
    Code:
    http://hondakarma.com/threads/\1/
    Many thanks.
     
  7. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    winner :)
     
    DeviateDefiant likes this.
  8. @Jake Bunce, if it's not too much trouble could you help me convert a few hard-referenced smilies from our old VB install too?

     
  9. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    For that I suggest a simple replacement query:

    Code:
    UPDATE xf_post
    SET message = REPLACE(message, 'http://accordownersclub.co.uk/images/smilies/', 'http://hondakarma.com/styles/default/xenforo/smilies/');
    
     
    DeviateDefiant likes this.
  10. Worked perfectly, many thanks.
     
  11. audiokid

    audiokid Active Member

    Last edited: Mar 23, 2014
  12. audiokid

    audiokid Active Member

  13. audiokid

    audiokid Active Member

    Cool, that helped but it doesn't rebuild the link unless I edit and save. ? Do I need to rebuild all the forum posts now? It still have those tags. Can I remove them now?
    Plus, it doesn't stream. Is there something I can do to stream SC now. Thanks guys! :)
     
  14. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Now that you have created the media site for soundcloud you just need to update old posts to use the new [media] tag in XenForo.

    Use this addon:

    http://xenforo.com/community/resources/post-content-find-replace.1549/

    Quick Find: [SC]https://soundcloud.com/

    Regular Expression: #\[SC\]https://soundcloud\.com/([\-a-z0-9_]+/[\-a-z0-9_]+)\[/SC\]#siU

    Replacement String: [media=soundcloud]\1[/media]

    That should do it. Backup first.
     
  15. audiokid

    audiokid Active Member

    YES! I am very grateful, Thanks :)
     
  16. audiokid

    audiokid Active Member

    That worked like a charm. But now when I add a new media like this:
    https://soundcloud.com/audiokid/better-by-morning-kultube

    it only created the link as it does here too. .

    If use the embed option in the editor, it produces an error?
     
    Last edited: Mar 23, 2014
  17. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Confirm these settings:

    http://xenforo.com/community/threads/add-more-video-sites-bb-code-media.7608/page-8#post-275009

    Especially this:

    And this:

    Admin CP -> Home -> Options -> Messages -> Auto-Embed Media Links
     
  18. audiokid

    audiokid Active Member

    I have all this the same and this selected here:
    Admin CP -> Home -> Options -> Messages -> Auto-Embed Media Links

    Auto-embed media, and add a link to the content within this BB code:
     
  19. audiokid

    audiokid Active Member

    Jake, I notice the same error message if I try and use the editor here too.
     
  20. audiokid

    audiokid Active Member

    Edit BB Code Media Site

    Does the code need to be an iframe instead?

    Code:
    <object height="81" width="100%">
    <param name="movie" value="http://player.soundcloud.com/player.swf?url=http%3A%2F%2Fsoundcloud.com%2F{$id}&amp;g=bb"></param>
    <param name="allowscriptaccess" value="always"></param>
    <embed allowscriptaccess="always" height="81" src="http://player.soundcloud.com/player.swf?url=http%3A%2F%2Fsoundcloud.com%2F{$id}&amp;g=bb" type="application/x-shockwave-flash" width="100%"></embed>
    </object>
     

Share This Page