I wasreading a couple of posts on navigation techniques for Tridon/ASP.NET - one of which Quirijn mentioned the possibility of using published structure group information.
I'm having a quick play with retrieving published structure group information via the API.Both small tests:
TaxonomyFactory tf = new TaxonomyFactory(); var k = tf.GetTaxonomyKeywords("tcm:71-3-4");And
TaxonomyHierarchyFormatter thf = new TaxonomyHierarchyFormatter(true); TaxonomyFactory tf = new TaxonomyFactory(); var k = tf.GetTaxonomyKeywords("tcm:71-3-4", thf);Always returns a Java.Lang.RuntimeException:
com.tridion.storage.StructureGroup cannot be cast to com.tridion.storage.Keyword
Which sort of makes sense as I's using a TCM of a structure group. But I'm not sure how else to retrieve structure groups as a taxonomy?
I'm assuming I still useTaxonomyFactory to retrieve this as it looks like everything is stored in the TAXFACETS alongside other keywords?
There is a StructureGroupCriteria class as part of the Query namespace but I think this will only give me published component content based on structure groups.
- Where someone suggest using published structure group information as Taxonomy Keywords?Pankaj Gaur– Pankaj Gaur2014-06-23 12:00:48 +00:00CommentedJun 23, 2014 at 12:00
- No-ones suggested that. But given that SG info is published to the Broker db in the same table (TAXFACETS) as keywords I reasonably assumed the same API could be used.Neil– Neil2014-06-23 12:02:46 +00:00CommentedJun 23, 2014 at 12:02
- Here's a previous question where RamG found SGs are available via the CD Webservice, but not API:stackoverflow.com/q/12202380Alvin Reyes– Alvin Reyes2014-07-09 18:44:43 +00:00CommentedJul 9, 2014 at 18:44
- Thanks Alvin, I had seen this post. Its just disappointing that this isn't made clear in the docs. The "Publish/Unpublish Structure Group Information" is only useful for 2011 in a scenario where you can leverage the OData web service. Either that or fix the API so it stops trying to casting to concrete types!Neil– Neil2014-07-09 19:37:26 +00:00CommentedJul 9, 2014 at 19:37
2 Answers2
I see what you're trying to do but I'm not sure how to get nested Structure Groups via the Content Delivery API in a way similar to Categories and Keywords.
Edit:Reading RamG's previous question, I don't think it's possible except via the CD Webservice:https://stackoverflow.com/q/12202380
One approach (hack) might be first getting Pages and then getting theirPaths orUrlPaths.
Get pages either with:
- Criteria filters or
PageMetaFactory.GetTaxonomyPages(Keyword, Boolean)to get Pages based on keywords. Provide aKeyword(as a "taxonomy facet") andTrueto include childkeywords for that keyword and this should return a list of Page or empty if nothing is found.
Then retrieve Path information, building the paths in delivery and removing duplicates (yes, very hackish). :-(
I'm guessing you're looking for more than the standard "publish XML based on SG" approach to maybe only retrieve "published" SGs in delivery?
Update (9 July 2014):
Publishing an SG with theStructure Group Hierarchy setting gets me values in the database but the following in delivery gets me Keyword IDs (Categories) but no Structure Groups.
foreach (var taxonomy in taxonomyFactory.GetTaxonomies(publicationId)) { writer.Write(taxonomy.ToString() + "<br/>"); }To publish Structure Groups, I needed to set:
- Publish Setting >Uncheck
Republish Only (Do Not Publish New Content) - Advanced
- Check Publish/Unpublish Structure Information
- Optionally use
Publish/Unpublish Content Items (default)
ITEM_CATEGORIES_AND_KEYWORDS has rows like:
RELATION_ID 19487 ITEM_REFERENCE_ID 6611 PUBLICATION_ID 69 TAXONOMY_ID 775KEYWORD_ID 775CATEGORY tcm:69-775-4KEYWORD tcm:69-775-4TAXFACET_TYPE 4And inTAXFACETS I see the Root SG:
NODE_ID 1202 FACET_ID 707PUBLICATION_ID 69TAXONOMY_ID 707FACET_NAME FACET_DESCRIPTION HomeFACET_KEY NULL...FACET_ITEMTYPE StructureGroupI don't get items (as Strings) back with GetTaxonomies
- Appreciate the input Alvin, but if we take a step back a bit - why make SGs publishable if there's no way to retrieve that info on the CD-side? How does SDL expect developers to use this information - or don't they?Neil– Neil2014-07-08 15:47:11 +00:00CommentedJul 8, 2014 at 15:47
- I agree. The docs explain we should use "Publish/Unpublish Structure Group Information" to "publish/unpublish the Structure Group hierarchy to the Content Delivery side where it is stored as a taxonomy." I edited my answer to point out I'm seeing SG IDs in
ITEM_CATEGORIES_AND_KEYWORDS, but notTAXFACETS. Did you do anything special to Publish them aside from the Publish/Unpublish setting?Alvin Reyes– Alvin Reyes2014-07-08 22:30:13 +00:00CommentedJul 8, 2014 at 22:30 - Only to make sure that under the Advanced tab in the Publish dialog that "Publish/Unpublish Structure Information" is ticked.Neil– Neil2014-07-09 10:17:17 +00:00CommentedJul 9, 2014 at 10:17
- Okay, same here but nothing in TAXFACETS on my side (Tridion 2013).Alvin Reyes– Alvin Reyes2014-07-09 14:59:46 +00:00CommentedJul 9, 2014 at 14:59
- This is 2011 SP1 HR1 - strange but this could have changed I guess. You have nothing for the following query then? - SELECT * FROM [Tridion_Broker].[dbo].[TAXFACETS] WHERE ITEM_SELECTOR = 'StructureGroup'Neil– Neil2014-07-09 17:36:53 +00:00CommentedJul 9, 2014 at 17:36
You can't use the Taxonomy APIs to fetch Structure Group data, simply because of the fact that they're two totally different things stored in totally different ways. In Tridion 2011, the only thing you could do on the .Net side of the CD API is query on that published Structure Group data:
// Get all pages to construct navigation in this SG and its child SGsStructureGroupCriteria sgCrit = new StructureGroupCriteria("tcm:24-2-4",true);Query q = new Query(sgCrit);// Should be pageIdsstring[]results = q.ExecuteQuery();See also theStructureGroupDirectory andStructureGroupTitle criteria classes in the .Net CD API.
- That's fine Raimond - so why is this feature even there then in 2011? How does SDL expect developers to utilise the "Publish SG information" feature? Are you saying things have changed in 2013? I also marked this down as I already mentioned the use of StructureGroupCriteria in my quesition.Neil– Neil2014-07-09 17:39:28 +00:00CommentedJul 9, 2014 at 17:39
Explore related questions
See similar questions with these tags.
