3

We want to move from http to https. Therefore we need a list of all external links in order to determine which ones have to be changes if external content is embedded. How can this be accomplished?

0
7

Solution 1. SPE

I recommend using Sitecore Powershell Extensions for that.

Example code snippet:

$fields = "Content", "Title"
$startPath = "/sitecore/content/Playground/Playground/int/Home"
$phrase = "http"

function Item-Report($i){
    $fields | % {
        if($i.Fields[$_] -ne $null -and $i.Fields[$_].Value.Contains($phrase) -eq $true){
            Write-Host $i.Paths.Path  "[" $_ "]"
        }        
    }
}

Get-ChildItem -Path $startPath -Recurse | % { Item-Report $_ }
  • $fields - defines list of fields that should be checked.
  • $startPath - this is start path. Root of all items you want to check
  • $phrase - text you want to search in all fields

If needed you can use Regex instead of basic Contains (note that url can be http or https), this is just an example code snippet.

Pros:

You can invoke Replace, editing each field so you don't have to do it manually.

Cons:

You need to install additional module if you haven't it already

Solution 2. SQL

You can try to get report using SQL Queries.

Example:

SELECT TOP 1000 [Id]
    ,[ItemId]
    ,[FieldId]
    ,[Value]
    ,[Created]
    ,[Updated]
    ,[DAC_Index]
FROM [sxa_sitecore_master].[dbo].[VersionedFields]
WHERE FieldId in ('8DBAF611-51C6-4A44-A0DB-92C3DC6DDAC9', '{D81F4C5A-71D0-497E-9612-CFC960165412}') 
AND Value LIKE '%http%'

Depending how you store your data you should check other fields as well.

  • [sxa_sitecore_master].[dbo].[SharedFields]
  • [sxa_sitecore_master].[dbo].[UnversionedFields]

Pros:

Very fast, no additional modules needed.

Cons:

You can easily get a report but writing an UPDATE command could be hard and risky. I would not do it.

2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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