0

I have an old image map that appears on 500+ pages. I would like to delete it and replace it with inline SVG. I know you can search and replace text, but is there a way to search and replace code on multiple pages? Our developers tell me Sitecore does not have that functionality, so editing the HTML is on a per-page basis. Is that true? I do not want to edit 500 pages by hand.

The image map HTML is stored in a RichText field.

As a last resort, if Sitecore does not allow search and replace of HTML, can I download the HTML, edit it, and then upload and overwrite the old pages? I am a content admin/content author, not a developer. Thanks for your help!

2
  • Can you explain in details where is the image map stored now (e.g. if that's a rich text field somewhere there) and what is expected new content?
    – Marek Musielak
    Feb 8, 2022 at 15:27
  • The code for the image map is in the rich text editor. The code was copied and pasted by using the HTML view within the RTE. I would like to replace the image map with an inline SVG version of the image. Hope that helps
    – Mt_F
    Feb 8, 2022 at 15:44

1 Answer 1

2

I suggest to use for such a case Sitecore Powershell Extension.

Pls make a backup package of your items before you run the script.

Your script will be something like :

#get root item
$root = gi master:// -id "{D64DCEAD-7154-4444-BAAC-B20288A9C5DE}"

# get all fields with are richtext 
$items = $root | ls -r | %{$item = $_; $_.Fields  | ?{$_.TypeKey -eq "rich text"} }
$items.Count
foreach($i in $items){
    
    Write-Host "Item Path" $i.Item.Paths.FullPath
    
    if($temp){
        clear-variable("temp")
    }
    if($replaced){
        clear-variable("replaced")
    }

    $replaced = $i.Value -replace 'texttobereplaced', 'newText'
    $temp = $i.Item
    $temp.Editing.BeginEdit()
    $temp.Fields[$i.Name].Value = $replaced
    $temp.Editing.EndEdit()
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.