Get all SmartForm items from Ektron 9 in a Taxonomy -
i'm using ektron cms version 9.0
i have smart form content allocated taxonomies e.g. might have 5 smart form content items (all of same) type allocated taxonomy, , 3 different taxonomy:
i need content of smart form type taxonomy:
public ienumerable<t> getlistofsmartformfromtaxonomy<t>(long taxonomyid, bool isrecursive) t : class { // todo }
what have working, based on links below, this:
public ienumerable<taxonomyitemdata> getlistofsmartformfromtaxonomy(long taxonomyid) { taxonomyitemcriteria criteria = new taxonomyitemcriteria(); criteria.addfilter(taxonomyitemproperty.taxonomyid, criteriafilteroperator.equalto, taxonomyid); taxonomyitemmanager taxonomyitemmanager = new taxonomyitemmanager(); list<taxonomyitemdata> taxonomyitemlist = taxonomyitemmanager.getlist(criteria); return taxonomyitemlist; }
but gets item's titles , ids, not smart form data itself.
as ektron newbie, don't know how items of 1 smart form type using 1 call (instead of looping through each item , fetching id not efficient)
what have missed? working on actively today , post findings here.
references used far:
- http://reference.ektron.com/developer/framework/organization/taxonomyitemmanager/getlist.asp
- ektron taxonomy , library items (in v9)
edit
posted just-got-it-working solution below fyi , awarded closest answer accepted. help. please chime in improvements ;)
i'd recommend using contenttaxonomycriteria contentmanager.
long smartformid = 42; long taxonomyid = 127; bool isrecursive = true; var cm = new contentmanager(); var taxonomycriteria = new contenttaxonomycriteria(); taxonomycriteria.addfilter(contentproperty.xmlconfigurationid, criteriafilteroperator.equalto, smartformid); taxonomycriteria.addfilter(taxonomyid, isrecursive); var content = cm.getlist(taxonomycriteria);
update
the contentdata
object has property called xmlconfiguration
. when content based on smartform, property non-null , have positive (non-zero) id: content[0].xmlconfiguration.id
example.
i add extension method code tell me whether given contentdata based on smart form:
public static class contentdataextensions { public static bool issmartformcontent(this contentdata content) { return content != null && content.xmlconfiguration != null && content.xmlconfiguration.id > 0; } }
that way can take content (or list of content) , check in code see if it's based on smartform or not:
foreach (var contentdata in contentlist) { if (contentdata.issmartformcontent()) { // smart-form stuff here... } }
of course, if content coming framework api , used criteria object selecting based on specific xmlconfigurationid, in theory wouldn't have use that, still comes in handy quite often.
Comments
Post a Comment