2

I was reading 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 use TaxonomyFactory 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 Jun 23 '14 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 Jun 23 '14 at 12:02
  • Here's a previous question where RamG found SGs are available via the CD Webservice, but not API: stackoverflow.com/q/12202380 – Alvin Reyes Jul 9 '14 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 Jul 9 '14 at 19:37
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 their Paths or UrlPaths.

Get pages either with:

  • Criteria filters or
  • PageMetaFactory.GetTaxonomyPages(Keyword, Boolean) to get Pages based on keywords. Provide a Keyword (as a "taxonomy facet") and True 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 the Structure 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            775
KEYWORD_ID             775
CATEGORY               tcm:69-775-4
KEYWORD                tcm:69-775-4
TAXFACET_TYPE          4

And in TAXFACETS I see the Root SG:

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

I 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 Jul 8 '14 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 not TAXFACETS. Did you do anything special to Publish them aside from the Publish/Unpublish setting? – Alvin Reyes Jul 8 '14 at 22:30
  • Only to make sure that under the Advanced tab in the Publish dialog that "Publish/Unpublish Structure Information" is ticked. – Neil Jul 9 '14 at 10:17
  • Okay, same here but nothing in TAXFACETS on my side (Tridion 2013). – Alvin Reyes Jul 9 '14 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 Jul 9 '14 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 SGs
StructureGroupCriteria sgCrit = new StructureGroupCriteria("tcm:24-2-4",true);
Query q = new Query(sgCrit);

// Should be pageIds
string[]results = q.ExecuteQuery();

See also the StructureGroupDirectory and StructureGroupTitle 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 Jul 9 '14 at 17:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.