Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • andywilde 25 posts 66 karma points
    Sep 22, 2015 @ 08:50
    andywilde
    0

    Update hyperlinks in all pages programmatically.

    We have a document repository outside of umbraco.

    The sub-domain name of this repository is changing and I will need to update hundreds of hyperlinks in content pages.

    Is there a way of doing this programmatically?

  • Laurence Gillian 600 posts 1219 karma points
    Sep 22, 2015 @ 09:31
    Laurence Gillian
    0

    Two approaches - SQL or C# depending on which you feel more confident with!

    SQL

    Please back your database up (I really do mean that!) and then write some SQL to update the Content in the [cmsPropertyData] table.

    Depending on your site and content, it could be as straight forward as using REPLACE, or you may need to use Regex to ensure you are only targeting that specific content.

    C#

    An alternative, would be to write a simple event handler that binds to the Publish event. On document publish, you could run a find and replace using C#, to update the content on specific properties.

    With this code in place, you would then republishing all of your documents, thus triggering the event handler, and updating the content in the database.

    Once you have republishing all your content, you could then remove the event handler.

    Let me know if you need a hand with the code for this,

    Cheers, Laurie

  • andywilde 25 posts 66 karma points
    Sep 22, 2015 @ 10:36
    andywilde
    0

    Thanks Laurence.

    I'd considered the SQL method but not sure if I was missing an inbuilt method within the umbraco classes or maybe an add-in package that would achieve this.

    I'll go ahead with the SQL approach as it seems the simplest.

    Thanks again Andy

Please Sign in or register to post replies

Write your reply to:

Draft