2

I have 2 templates:

  • Template A: PersonalTemplate
  • Template B: PrivateTemplate

Here I want to inherit Template B in Template A using the PowerShell script.

  • It sounds like you just need to set the Base template field (__Base template). Is that what you're hoping to do? If so, you should be able to find what you need here: doc.sitecorepowershell.com/… – Dan Sinclair Mar 21 at 13:46
6

Sitecore PowerShell has a function called Add-BaseTemplate. This function can add one or more base templates to a template item.

There are multiple ways to call it, but the simplest is to get both template items and then pass those to the function:

Add-BaseTemplate -Item <Item> -TemplateItem <TemplateItem[]>

You can use that to add Template B to the base templates for Template A like this:

$templateB = Get-Item master:\templates\path\to\TemplateB
$templateA = Get-Item master:\templates\path\to\TemplateA

Add-BaseTemplate -Item $templateA -TemplateItem $templateB

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.