Friday, June 30, 2023

How to fix Docker Sitecore Next JSS setup issue : The certificate chain was issued by an authority that is not trusted.

This blog will help you if you are trying to set up the Sitecore Next JSS application using Docker and come across an error -' The certificate chain was issued by an authority that is not trusted '

Error Screenshot:



Follow the following steps to resolve the issue:

1. Go to the file - 'nuget.config' and change HTTPS to HTTP as shown below.

    <add key="Nuget" value="http://api.nuget.org/v3/index.json" />
    <add key="Sitecore" value="http://sitecore.myget.org/F/sc-packages/api/v3/index.json" />



2. Go to file - 'Dockerfile' and comment out the following command.
          
        RUN nuget restore -Verbosity quiet




3. Go to the file- '\docker\build\nodejs\Dockerfile' and change the command as shown in the screenshot below.

RUN curl.exe -sS -k -L -o node.zip https://nodejs.org/dist/v%NODEJS_VERSION%/node-v%NODEJS_VERSION%-win-x64.zip"





                                                          Hope this helps. Happy learning!

How to change placeholder key of rendering using PowerShell script in Sitecore?

Updating bulk content items manually might not be the best practice when dealing with bulk items.

This blog will help you update the placeholder key of renderings using the PowerShell script more efficiently. The following code snippet will be used to change the placeholder key of the rendering to the page programmatically using the PowerShell script.

This code should work with any version of Sitecore. 

Open - Development Tools -> PowerShell ISE and paste the following code.

Modify the paths and fields according to your template fields.


Update the placeholder key of the rendering on the existing page

PowerShell script code:    

$masterdatabase = "master"

$rootItem = Get-Item -Path (@{$true="$($masterdatabase):\sitecore\content\ArticleName\2023"; $false="$($masterdatabase):\content"}[(Test-Path -Path "$($masterdatabase):\sitecore\content\Home")])


$defaultLayout = Get-LayoutDevice "Default"

# Toggle for whether to update Shared or Final Layout

$useFinalLayout = $True

# If set to true, the script will only list the renderings that need fixing, rather than fixing them.

$reportOnly = $False

foreach ( $item in Get-ChildItem -Item $rootItem -Recurse )

{

    # Only interested in items that have a layout

    

    if (Get-Layout $item)

    {

      $itemTemplate = [Sitecore.Data.Managers.TemplateManager]::GetTemplate($item)

      if($itemTemplate.ID -eq "{HJUIUOOOL-4B42-4AD9-94F9-JKU78JJHH}")

      {

           

            $renderings =  Get-Rendering -Item $item -FinalLayout

            #Write-Host "$($item.FullPath) -($renderings)"

            foreach ( $rendering in $renderings )

            {

                # Only update the rendering if we're not in "Report Only" mode

                if (!$reportOnly)

                {

                    if($rendering.Placeholder -eq "sideBar")

                    {

                        $rendering.Placeholder = $rendering.Placeholder -replace "sideBar", "jss-article-sidebar"

                        Set-Rendering -Item $item -Instance $rendering -FinalLayout:$useFinalLayout

                        Write-Host "$($item.FullPath) - Rendering $($rendering.UniqueID) - Placeholder: $("sideBar") --> $("jss-article-sidebar")"

                    }

                    if($rendering.Placeholder -eq "main")

                    {

                        $rendering.Placeholder = $rendering.Placeholder -replace "main", "jss-main"

                        Set-Rendering -Item $item -Instance $rendering -FinalLayout:$useFinalLayout

                        Write-Host "$($item.FullPath) - Rendering $($rendering.UniqueID) - Placeholder: $("main") --> $("jss-main")"

                    }

                    if($rendering.Placeholder -eq "header")

                    {

                        $rendering.Placeholder = $rendering.Placeholder -replace "header", "jss-header"

                        Set-Rendering -Item $item -Instance $rendering -FinalLayout:$useFinalLayout

                        Write-Host "$($item.FullPath) - Rendering $($rendering.UniqueID) - Placeholder: $("header") --> $("jss-header")"

                    }

                    if($rendering.Placeholder -eq "footer")

                    {

                        $rendering.Placeholder = $rendering.Placeholder -replace "footer", "jss-footer"

                        Set-Rendering -Item $item -Instance $rendering -FinalLayout:$useFinalLayout

                        Write-Host "$($item.FullPath) - Rendering $($rendering.UniqueID) - Placeholder: $("footer") --> $("jss-footer")"

                    }

                }

            }

        }

    }

}



How to Create a Public Link Using the Sitecore Content Hub REST API

Creating a public link using the Sitecore Content Hub REST API is a straightforward process that enables you to share content externally whi...