Get Taxa of a Content item
IQueryable<
Video
> videos = App.WorkWith().Videos().Get()
.Where(v => v.Status == ContentLifecycleStatus.Live);
foreach (Video v in videos)
v.Organizer???
Hello Adam,
Please take a look at this forum post
http://www.sitefinity.com/devnet/forums/sitefinity-4-x/sdk/sitefinity-4-0-taxonomy-categorization.aspx#1454545
Greetings,
Ivan Dimitrov
the Telerik team
I've seen that post. It was helpful in finding Content given a specific Taxonomy. I'm looking to find a full listing of all videos and their associated taxonomies.
Or were you suggesting the route of getting the taxonomies I am interested in first, then get all of the videos matching each taxonomy and merging the list? I was hoping for < O(2n).
Hello Adam,
Each content item has a property GetValue where you can pass the dybanic filed name
cnt.GetValue("Category"), so you can get the category for a specific item.
Greetings,
Ivan Dimitrov
the Telerik team
www.sitefinity.com/.../allmembers_t_telerik_sitefinity_libraries_model_video.html
There is no GetValue method according to both your docs and my own experimentation. How do I get that?
I am writing my own WCF Service to avoid requiring authentication to get the video attributes. I will have to use the query by taxon method and merge lists when multiple categories are selected.
So I have a solution now. I would still like to know how to call the GetValue method as it doesn't appear to be a member of any Content class I have worked with, but is referenced often on the forum.
Hello Adam,
GetValue(string) method is an extension method defined on the type IDynamicFieldsContainer. In order to have this method available, please import following namespace in your class:
Telerik.Sitefinity.Model
Yes, I know that this is, suboptimal, to say the least. I'll try to see if and when we can move this into Telerik.Sitefinity namespace, because it would be more obvious.
I hope this helps.
so we can get the specific taxa list by specifying the taxonomy field via GetValue("taxonomyname")
HOWEVER, this requires that we know in advance the name of the custom field storing the value. Is it possible, as the OP asked, to get a list of ALL taxonomies including their types from the content item directly without specifying the taxonomy name?
For example, if I'm processing items via API and need to do something based on the taxonomy coming from different content types (Which may have different custom fields for taxonomy) I can't assume they have a field or not, so I want to be able to simply get a result of all the taxonomy and types and process it that way...
is this not possible?
Hello Josh,
You can use type descriptor to get all properties of the item and iterate them. Then you have to get the property descriptor and get the value.
public
void
GetTaxons(IDynamicFieldsContainer item)
var allProperties = TypeDescriptor.GetProperties(item);
foreach
(PropertyDescriptor propertyDescriptor
in
allProperties)
if
(propertyDescriptor
is
TaxonomyPropertyDescriptor)
var value = item.GetValue<IList<Guid>>(propertyDescriptor.Name).ToArray();