In event code for Tridion 2011
OnPagePublishPost method, I want to get Category and Keywords value from Metadata of a Component. The metadata field in the Schema is as below:
Field Type : Text
The Checkboxes Values will be Selected from a List and Category are checked.
List Type: Checkboxes
I have created a Category called "Sections" and have added Keywords to it. Those Keywords show as checkboxes in the Component. I want to get the Keyword values from the Component. The code which I have written is :
Component compSource = null; //page is the object of Page and is passed in the parameter. compSource = page.ComponentPresentations.Component; ItemFields fieldsMetaCommon = new ItemFields(compSource.Metadata, compSource.MetadataSchema); //Getting section keywords //pr_section is a field in MetaDataDesign of the schema with Type as Text and with the configuration of values will be selected from list and Categories checked. KeywordField fieldSection = (KeywordField)fieldsMetaCommon["pr_section"]; Keyword fieldSectionkeyword = fieldSection.Value;
In component Metadata, I have selected a category and the keywords related to it are 6 as of nowand they are checkboxes, which means that the component will be tagged with multiple keywords. I am not sure how will I loop through the keywords as they are multiple. Nickoli gave me the code but i assume it will work for only a single keyword in a category.