// Returns the navigation node that corresponds to this content. If // we give it a navigation node already, it'll return that node, so // no harm done. public string GetNavigationNode() { // Load the contentItem. If we get a Toc entry, then we know it is // a navigation node rather than a content node. The reason is that // getNavigationPaths only returns the root node if the target node is // a navigation node already. We could check to see if we get one path // consisting of one node, but the user could give a target node that is // the same as the root node. Perf isn't an issue because this should // only be called once with the rootNode. this.Load(false); // Don't load images in case we are a content node. if (toc != null) { return(contentId); } navigationKey root = new navigationKey(); root.contentId = rootContentItem.contentId; root.locale = locale; root.version = rootContentItem.version; navigationKey target = new navigationKey(); // target.contentId = "AssetId:" + assetId; target.contentId = contentId; target.locale = locale; target.version = collection + "." + version; ContentService proxy = new ContentService(); getNavigationPathsRequest request = new getNavigationPathsRequest(); request.root = root; request.target = target; getNavigationPathsResponse response = proxy.GetNavigationPaths(request); // We need to deal with the case where the content appears in many // places in the TOC. For now, just use the first path. if (response.navigationPaths.Length == 0) { return(null); } // This is the last node in the first path. return(response.navigationPaths[0].navigationPathNodes[ response.navigationPaths[0].navigationPathNodes.Length - 1].navigationNodeKey.contentId); }
// Returns the navigation node that corresponds to this content. If // we give it a navigation node already, it'll return that node, so // no harm done. public string GetNavigationNode() { // Load the contentItem. If we get a Toc entry, then we know it is // a navigation node rather than a content node. The reason is that // getNavigationPaths only returns the root node if the target node is // a navigation node already. We could check to see if we get one path // consisting of one node, but the user could give a target node that is // the same as the root node. Perf isn't an issue because this should // only be called once with the rootNode. Load(false); // Don't load images in case we are a content node. if (Toc != null) { return(ContentId); } var root = new navigationKey { contentId = RootContentItem.ContentId, locale = _locale, version = RootContentItem.Version }; var target = new navigationKey { contentId = ContentId, locale = _locale, version = _collection + "." + _version }; // target.contentId = "AssetId:" + assetId; var client = new ContentServicePortTypeClient("ContentService"); var request = new GetNavigationPathsRequest1 { getNavigationPathsRequest = { target = target, root = root } }; var response = client.GetNavigationPaths(request); // We need to deal with the case where the content appears in many // places in the TOC. For now, just use the first path. if (response.getNavigationPathsResponse.navigationPaths.Length == 0) { return(null); } // This is the last node in the first path. return(response.getNavigationPathsResponse.navigationPaths[0].navigationPathNodes[response.getNavigationPathsResponse.navigationPaths[0].navigationPathNodes.Length - 1].navigationNodeKey.contentId); }
// Returns the navigation node that corresponds to this content. If // we give it a navigation node already, it'll return that node, so // no harm done. public string GetNavigationNode() { // Load the contentItem. If we get a Toc entry, then we know it is // a navigation node rather than a content node. The reason is that // getNavigationPaths only returns the root node if the target node is // a navigation node already. We could check to see if we get one path // consisting of one node, but the user could give a target node that is // the same as the root node. Perf isn't an issue because this should // only be called once with the rootNode. Load(false); // Don't load images in case we are a content node. if (Toc != null) return ContentId; var root = new navigationKey { contentId = RootContentItem.ContentId, locale = _locale, version = RootContentItem.Version }; var target = new navigationKey { contentId = ContentId, locale = _locale, version = _collection + "." + _version }; // target.contentId = "AssetId:" + assetId; var client = new ContentServicePortTypeClient("ContentService"); var request = new GetNavigationPathsRequest1 { getNavigationPathsRequest = {target = target, root = root} }; var response = client.GetNavigationPaths(request); // We need to deal with the case where the content appears in many // places in the TOC. For now, just use the first path. if (response.getNavigationPathsResponse.navigationPaths.Length == 0) return null; // This is the last node in the first path. return response.getNavigationPathsResponse.navigationPaths[0].navigationPathNodes[response.getNavigationPathsResponse.navigationPaths[0].navigationPathNodes.Length - 1].navigationNodeKey.contentId; }