2

I have a Category TCMID and required a name of this through DD4T,

I am able to get allkyewords of this category, But unable to find any option to get the Category Name in DD4T View.

DD4T.Factories.TaxonomyFactory taxFactory = new DD4T.Factories.TaxonomyFactory();

string catgoryTcmUri = "tcm:45-6200-512"; // coming from app.config file

List<IKeyword> keyword = taxFactory.GetAllKeyword(catgoryTcmUri);
//by this keyword object, I am getting all child keywords. 

In current scenario, I am getting the category TCMID from config file, I want to get the name/title of this value.

Is there any other way to get this?

  • in which context you want to do it, in Templating or CD side? Please explain it in your question. – Saurabh Gangwar Mar 13 '15 at 13:56
  • @SaurabhGangwar, I need it, this in razor view in DD4t – Priyank Gupta Mar 13 '15 at 14:05
  • 1
    Can you edit your question and show the code you use for getting the keywords, I'm sure that improves your chances on a useful answer – Bart Koopman Mar 13 '15 at 16:30
1

If you have a component or page which contains a value from the category, you can get to the category's ID through:

component.Categories[...].ID

If this is not the case, you will need to retrieve the category from Tridion using the CD api. I think this is possible with an ItemTypeCriteria combined with an ItemTitleCriteria, like this:

Criteria typeCriteria = new ItemTypeCriteria(512);
Criteria titleCriteria = new ItemTitleCriteria("MyCategory");
Query q = new Query(new AndCriteria(typeCriteria, titleCriteria));

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.