Last active
July 7, 2016 02:12
-
-
Save poojarsn/9e4c3d1481cdd54334bd121f5fe6bff6 to your computer and use it in GitHub Desktop.
Sitecore Powershell Extension: Create User defined Template Item
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
##--INPUT --## | |
$customTemplateName = "test6"; | |
$baseTemplate="{1930BBEB-7805-47158AC7CF696}|{B7B41C45-2A6-E377DE778095}|{96224572-74-AE7E-DE43F0F6BFD9}"; | |
$layoutRenderings= | |
'<r xmlns:xsd="http://www.w3.org/2001/XMLSchema" > | |
<d id="{FE5D7FDF-89C0-4D99-9AA3-B5FBD009C9F3}" l="{19432667-2790-44EC-9673-ACAE93AE0519}"> | |
<r id="{7915EF7B--7B0D39137443}" ph="metaheader" uid="{D36E7AFC-08B5-433C13-554B20BE9569}" /> | |
<r id="{016A19CB837-E81F2B510E72}" ph="breadcrumb" uid="{2ABC1220-6C40-426-B0A2-F594EEC98D7E}" /> | |
<r id="{C5CF5F45-F21BAE6-52DBC568E33A}" ph="navheader" uid="{DA646F0700E-B09A26C8}" /> | |
<r id="{93FA9D3A-590A-467C-872F-830C1D17E147}" ph="banner" uid="{8B8E75580AF0C-32620B307B5C}" /> | |
<r id="{545F506A-934-8A6C-B3414651647C}" ph="help" uid="{5C527DC3-CDA9--7A401E051A08}" /> | |
<r id="{342ACC72-855B-41944A31B03DEF5}" ph="navfooter" uid="{52EEC507-C-9DF9-E005FCE4FCAF}" /> | |
</d> | |
</r>' | |
##--Step 1 Create New Userdefined Template | |
$path = "master:\sitecore\templates\User Defined\ABC\Pages\"+$customTemplateName; | |
New-Item -Path $path -ItemType "/sitecore/templates/System/Templates/Template" | |
$item = Get-Item -Path $path | |
##--Step 2 Update Standard Fields-****Base template***** | |
$item."__base template" = $baseTemplate | |
##--Step 3 Create Template Standard Values Item | |
$pathStandardValue= "master:\sitecore\templates\User Defined\ABC\Pages\"+$customTemplateName+"\__Standard Values"; | |
$itemTypeStandardValueTemplate="/sitecore/templates/User Defined/ABC/Pages/"+$customTemplateName; | |
New-Item -path $pathStandardValue -ItemType $itemTypeStandardValueTemplate | |
##--Step 4 Update Standard Values | |
$item."__standard values" = "sitecore/templates/User Defined/ABC/Pages/"+ $customTemplateName +"/__Standard Values" | |
##--Step 5 Set/Assign Presentation Layout and renderings in above standard value item | |
$standardItem = Get-Item -Path $pathStandardValue | |
$standardItem."__renderings"= $layoutRenderings | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment