2

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.

askedJun 23, 2014 at 9:13
Neil's user avatar
4
  • Where someone suggest using published structure group information as Taxonomy Keywords?CommentedJun 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.CommentedJun 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/12202380CommentedJul 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!CommentedJul 9, 2014 at 19:37

2 Answers2

2

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") andTrue to 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 >UncheckRepublish Only (Do Not Publish New Content)
  • Advanced
    • Check Publish/Unpublish Structure Information
    • Optionally usePublish/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          4

And inTAXFACETS I see the Root SG:

NODE_ID            1202 FACET_ID           707PUBLICATION_ID     69TAXONOMY_ID        707FACET_NAME             FACET_DESCRIPTION  HomeFACET_KEY          NULL...FACET_ITEMTYPE     StructureGroup

I don't get items (as Strings) back with GetTaxonomies

answeredJul 7, 2014 at 17:04
Alvin Reyes's user avatar
6
  • 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?CommentedJul 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 inITEM_CATEGORIES_AND_KEYWORDS, but notTAXFACETS. Did you do anything special to Publish them aside from the Publish/Unpublish setting?CommentedJul 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.CommentedJul 9, 2014 at 10:17
  • Okay, same here but nothing in TAXFACETS on my side (Tridion 2013).CommentedJul 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'CommentedJul 9, 2014 at 17:36
1

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.

answeredJul 9, 2014 at 16:42
Raimond's user avatar
1
  • 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.CommentedJul 9, 2014 at 17:39

Your Answer

Sign up orlog in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

By clicking “Post Your Answer”, you agree to ourterms of service and acknowledge you have read ourprivacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.