/ Published in: C#
The following code retrieves a list of content based on a taxonomy id. The list is bound to a repeater that display a preview of the content with a quick link to a content page. The content comes in based on the previous taxonomy id but exposes a content list which can be used gather the html property's. Then I use a regex to take our specific nodes for the preview columns in my table.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
//Global Variables public MatchCollection priceMatch; public MatchCollection bathroomCollection; public MatchCollection bedroomCollection; public MatchCollection LandsizeCollection; /* List content based on taxonomy */ criteria.AddFilter(TaxonomyItemProperty.TaxonomyName, CriteriaFilterOperator.EqualTo, community_name); List<TaxonomyItemData> ccdata = manager.GetList(criteria); /* Gather content preview info */ ContentTaxonomyCriteria criteria1 = new ContentTaxonomyCriteria(ContentProperty.Id, EkEnumeration.OrderByDirection.Ascending); /* Filter content based on taxonomy id based on the previous criteria filter */ criteria1.AddFilter(ccdata[0].TaxonomyId, true); List<ContentData> contentList1 = cm.GetList(criteria1); /* Parse xml to get price of specific mhc property */ dt.Columns.Add("PropertyName"); dt.Columns.Add("Bed"); dt.Columns.Add("Bath"); dt.Columns.Add("SquareFeet"); dt.Columns.Add("PricePerMonth"); dt.Columns.Add("Link"); for (int i = 0; i < contentList1.Count; i++) { priceMatch = regexPrice.Matches(contentList1[i].Html); foreach (Match m in priceMatch) { prices.Add(m.Value); } bathroomCollection = regexBathrooms.Matches(contentList1[i].Html); foreach (Match m in bathroomCollection) { bathrooms.Add(m.Value); } bedroomCollection = regexBedrooms.Matches(contentList1[i].Html); foreach (Match m in bedroomCollection) { bedrooms.Add(m.Value); } LandsizeCollection = regexLandsize.Matches(contentList1[i].Html); foreach (Match m in LandsizeCollection) { sqft.Add(m.Value); } dt.Rows.Add(contentList1[i].Title, bedrooms[i], bathrooms[i], sqft[i], prices[i], contentList1[i].Quicklink); } Repeater1.DataSource = dt; Repeater1.DataBind();
URL: http://i49.tinypic.com/345nacp.jpg