1

I would like to know, how can we access the components linked to a particular Keyword in SDL Web 8, from our DXA Java web application.

Currently I do not see any field in my WebApp that maps to the component list for any keyword.

I see this link has it detailed for an Array of keywords. Is there anyway to do it for individual keywords.

As getTaxonomyContent takes the following parameters:

  • an array of Keywords

  • a Boolean to include branches (true) of the passed Keywords to
    retrieve content for, otherwise false for only content relating
    directly to the Keyword

  • (optional) an additional Criteria (
    Com.Tridion.Broker.Querying.Criteria.Criteria)

https://docs.sdl.com/LiveContent/content/en-US/SDL%20Web-v5/GUID-AE9E11C7-9B02-4F55-99E2-8E6C69DA8B0F

Any help/suggestion would be really appreciated. TIA.

enter image description here

enter image description here

  • It seems like you have already answered your own question? You have found the API to get classified Components for a given (set of) Keyword(s). Ok, it takes an array of Keywords, but you can create an array containing one item, right? – Rick Pannekoek May 24 '18 at 7:17
  • Yes, I can, however, the below line keeps requiring the 'criteria' even though its optional: String[] foundComponentURIS = relationManager.GetTaxonomyContent(selectedKeywords, false, criteria); – guest_2017 May 24 '18 at 7:24
  • Is it worth adding your code and the exact error to the example? Maybe there's an issue with the variable criteria itself? – Dylan .. Mark Saunders May 24 '18 at 9:16
0

In that documentation link, componentItemType variable should be corrected to criteria

GetTaxonomyContent has following API methods:

    public string[] GetTaxonomyContent(Keyword taxonomyKeyword, bool includeBranches);
    public string[] GetTaxonomyContent(Keyword[] taxonomyKeywords, bool includeBranches);
    public string[] GetTaxonomyContent(Keyword taxonomyKeyword, bool includeBranches, Criteria additionalCriteria);
    public string[] GetTaxonomyContent(Keyword[] taxonomyKeywords, bool includeBranches, Criteria additionalCriteria);

Example with criteria:

int iComponentItemType = 16;
String selectedKeywordURI = "tcm:12-800-1024";
Keyword selectedKeywords;
TaxonomyFactory taxonomyFactory = new TaxonomyFactory();
selectedKeywords = taxonomyFactory.GetTaxonomyKeyword(selectedKeywordURI);
TaxonomyRelationManager relationManager = new TaxonomyRelationManager();
ItemTypeCriteria criteria = new ItemTypeCriteria(iComponentItemType);
String[] foundComponentURIS = relationManager.GetTaxonomyContent(selectedKeywords, true, criteria);

Example without criteria (optional):

String selectedKeywordURI = "tcm:12-800-1024";
Keyword selectedKeywords;
TaxonomyFactory taxonomyFactory = new TaxonomyFactory();
selectedKeywords = taxonomyFactory.GetTaxonomyKeyword(selectedKeywordURI);
TaxonomyRelationManager relationManager = new TaxonomyRelationManager();
String[] foundItemsURIS = relationManager.GetTaxonomyContent(selectedKeywords, true);

I hope it helps.

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.