Last active
June 6, 2018 10:51
Revisions
-
justsayantan revised this gist
Jun 6, 2018 . 1 changed file with 18 additions and 26 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -12,38 +12,30 @@ Function AddItemToBundle ) Begin { $client = Get-TridionCoreServiceClient -Verbose:($PSBoundParameters['Verbose'] -eq $true); $readOptions = New-Object Tridion.ContentManager.CoreService.Client.ReadOptions; } Process { $bundle = Get-TridionItem -id $BundleId; $doc = New-Object System.Xml.XmlDocument; $doc.LoadXml($bundle.Configuration) $itemElem = $doc.CreateElement('Item', $BundleNamespace); $itemElem.SetAttribute('href', $XLinkNamespace, $itemId) | Out-Null; $rootElem = $doc.SelectSingleNode('/*/*'); $rootElem.appendChild($itemElem) | Out-Null; $bundle.Configuration = $doc.InnerXml; $client.Save($bundle, $readOptions); } End { Close-TridionCoreServiceClient $client; } } -
justsayantan revised this gist
Jun 5, 2018 . 1 changed file with 0 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -2,7 +2,6 @@ public static void AddItemToBundle(string bundleId, string itemId) { CoreServiceClient _CoreServiceClient = Utility.GetCoreServiceSettings(); ReadOptions _readOption = new ReadOptions(); VirtualFolderData bundle = (VirtualFolderData)_CoreServiceClient.Read(bundleId, _readOption); XmlDocument bundleConfiguration = new XmlDocument(); bundleConfiguration.LoadXml(bundle.Configuration); -
justsayantan revised this gist
Jun 5, 2018 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -6,9 +6,9 @@ Function AddItemToBundle [Parameter(Mandatory=$true)] [string]$BundleId, # Item ID . [Parameter(Mandatory=$true)] [string]$ItemID ) Begin -
justsayantan revised this gist
Jun 5, 2018 . 1 changed file with 28 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,28 @@ public static void AddItemToBundle(string bundleId, string itemId) { CoreServiceClient _CoreServiceClient = Utility.GetCoreServiceSettings(); ReadOptions _readOption = new ReadOptions(); //string bundleId = "tcm:5-1076-8192"; VirtualFolderData bundle = (VirtualFolderData)_CoreServiceClient.Read(bundleId, _readOption); XmlDocument bundleConfiguration = new XmlDocument(); bundleConfiguration.LoadXml(bundle.Configuration); XmlNameTable nameTable = new NameTable(); nameTable = bundleConfiguration.NameTable; XmlNamespaceManager namespaceManager = new XmlNamespaceManager(nameTable); namespaceManager.AddNamespace("b", @"http://www.sdltridion.com/ContentManager/Bundle"); namespaceManager.AddNamespace("xlink", @"http://www.w3.org/1999/xlink"); XmlNode itemsElement = bundleConfiguration.SelectSingleNode("/b:Bundle/b:Items", namespaceManager); XmlElement itemElement = itemsElement.OwnerDocument.CreateElement("Item", @"http://www.sdltridion.com/ContentManager/Bundle"); XmlAttribute xmlAttr = itemElement.OwnerDocument.CreateAttribute("xlink", "href", "http://www.w3.org/1999/xlink"); xmlAttr.Value = itemId; XmlAttribute xmlAttr1 = itemElement.OwnerDocument.CreateAttribute("xlink", "type", "http://www.w3.org/1999/xlink"); xmlAttr1.Value = "simple"; itemElement.SetAttributeNode(xmlAttr); itemElement.SetAttributeNode(xmlAttr1); itemsElement.AppendChild(itemElement); bundle.Configuration = bundleConfiguration.InnerXml; _CoreServiceClient.Save(bundle, _readOption); } -
justsayantan created this gist
Jun 5, 2018 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,49 @@ Function AddItemToBundle { [CmdletBinding()] Param ( # Bundle ID [Parameter(Mandatory=$true)] [string]$BundleId, # Item ID . [Parameter(Mandatory=$true)] [string]$ItemID ) Begin { $client = Get-TridionCoreServiceClient -Verbose:($PSBoundParameters['Verbose'] -eq $true); } Process { $readOptions = New-Object Tridion.ContentManager.CoreService.Client.ReadOptions; $bundle = Get-TridionItem -id $BundleId [xml]$bundleConfiguration = $bundle.Configuration [xml]$bundelItems = $bundleConfiguration.Bundle.Items.OuterXml [System.Xml.XmlNameTable] $nameTable = $bundleConfiguration.NameTable [System.Xml.XmlNamespaceManager] $namespaceManager = $nameTable; $namespaceManager.AddNamespace('b', 'http://www.sdltridion.com/ContentManager/Bundle'); $namespaceManager.AddNamespace('xlink', 'http://www.w3.org/1999/xlink'); [System.Xml.XmlNode] $itemsElement = $bundleConfiguration.SelectSingleNode("/b:Bundle/b:Items", $namespaceManager); [System.Xml.XmlElement] $itemElement = $itemsElement.OwnerDocument.CreateElement('Item', 'http://www.sdltridion.com/ContentManager/Bundle'); [System.Xml.XmlAttribute] $xmlAttr = $itemElement.OwnerDocument.CreateAttribute('xlink', 'href', 'http://www.w3.org/1999/xlink'); $xmlAttr.Value = $ItemID; [System.Xml.XmlAttribute] $xmlAttr1 = $itemElement.OwnerDocument.CreateAttribute('xlink', 'type', 'http://www.w3.org/1999/xlink'); $xmlAttr1.Value = "simple"; $itemElement.SetAttributeNode($xmlAttr); $itemElement.SetAttributeNode($xmlAttr1); $itemsElement.AppendChild($itemElement); $bundle.Configuration = $bundleConfiguration.InnerXml; $client.Save($bundle, $readOption); } End { Close-TridionCoreServiceClient $client; } }