Return to Snippet

Revision: 62729
at March 8, 2013 05:52 by dego89


Updated Code
//Global Variables
    public MatchCollection priceMatch;
    public MatchCollection bathroomCollection;
    public MatchCollection bedroomCollection;
    public MatchCollection LandsizeCollection;

/* List content based on taxonomy */
        TaxonomyItemManager manager = new TaxonomyItemManager();
        TaxonomyItemCriteria criteria = new TaxonomyItemCriteria();
        criteria.AddFilter(TaxonomyItemProperty.TaxonomyName, CriteriaFilterOperator.EqualTo, community_name);
        List<TaxonomyItemData> ccdata = manager.GetList(criteria);


        /* Gather content preview info */
        ContentManager cm = new ContentManager();
        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 */
        Regex regexPrice = new Regex(@"(?<=\bPropertyTax>\b)[0-9\,]+");
        Regex regexBathrooms = new Regex(@"(?<=\bBathrooms>\b)[0-9\,]+");
        Regex regexBedrooms = new Regex(@"(?<=\bBedrooms>\b)[0-9\,]+");
        Regex regexLandsize = new Regex(@"(?<=\bLandSize>\b)[a-z0-9\,\.\'\ ]+");

        DataTable dt = new DataTable();
        dt.Columns.Add("PropertyName");
        dt.Columns.Add("Bed");
        dt.Columns.Add("Bath");
        dt.Columns.Add("SquareFeet");
        dt.Columns.Add("PricePerMonth");
        dt.Columns.Add("Link");

        List<string> prices = new List<string>();
        List<string> bathrooms = new List<string>();
        List<string> bedrooms = new List<string>();
        List<string> sqft = new List<string>();
        
        

        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();

Revision: 62728
at March 8, 2013 05:47 by dego89


Updated Code
/* List content based on taxonomy */
        TaxonomyItemManager manager = new TaxonomyItemManager();
        TaxonomyItemCriteria criteria = new TaxonomyItemCriteria();
        criteria.AddFilter(TaxonomyItemProperty.TaxonomyName, CriteriaFilterOperator.EqualTo, community_name);
        List<TaxonomyItemData> ccdata = manager.GetList(criteria);


        /* Gather content preview info */
        ContentManager cm = new ContentManager();
        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 */
        Regex regexPrice = new Regex(@"(?<=\bPropertyTax>\b)[0-9\,]+");
        Regex regexBathrooms = new Regex(@"(?<=\bBathrooms>\b)[0-9\,]+");
        Regex regexBedrooms = new Regex(@"(?<=\bBedrooms>\b)[0-9\,]+");
        Regex regexLandsize = new Regex(@"(?<=\bLandSize>\b)[a-z0-9\,\.\'\ ]+");

        DataTable dt = new DataTable();
        dt.Columns.Add("PropertyName");
        dt.Columns.Add("Bed");
        dt.Columns.Add("Bath");
        dt.Columns.Add("SquareFeet");
        dt.Columns.Add("PricePerMonth");
        dt.Columns.Add("Link");

        List<string> prices = new List<string>();
        List<string> bathrooms = new List<string>();
        List<string> bedrooms = new List<string>();
        List<string> sqft = new List<string>();
        
        

        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();

Revision: 62727
at March 8, 2013 02:25 by dego89


Updated Code
/* List content based on taxonomy */
        TaxonomyItemManager manager = new TaxonomyItemManager();
        TaxonomyItemCriteria criteria = new TaxonomyItemCriteria();
        criteria.AddFilter(TaxonomyItemProperty.TaxonomyName, CriteriaFilterOperator.EqualTo, community_name); //coomunity_name can be any string you need
        List<TaxonomyItemData> ccdata = manager.GetList(criteria);


        /* Gather content preview info */
        ContentManager cm = new ContentManager();
        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 specific node, in this case, the price node */
        Regex regex = new Regex(@"(?<=\bPrice>\b)[0-9\,]+");
        //Match priceMatch;

        for (int i = 0; i < contentList1.Count; i++)
        {
            priceMatch = regex.Match(contentList1[i].Html);
            
        }

Revision: 62726
at March 8, 2013 02:23 by dego89


Initial Code
/* List content based on taxonomy */
        TaxonomyItemManager manager = new TaxonomyItemManager();
        TaxonomyItemCriteria criteria = new TaxonomyItemCriteria();
        criteria.AddFilter(TaxonomyItemProperty.TaxonomyName, CriteriaFilterOperator.EqualTo, community_name);
        List<TaxonomyItemData> ccdata = manager.GetList(criteria);


        /* Gather content preview info */
        ContentManager cm = new ContentManager();
        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 specific node, in this case, the price node */
        Regex regex = new Regex(@"(?<=\bPrice>\b)[0-9\,]+");
        //Match priceMatch;

        for (int i = 0; i < contentList1.Count; i++)
        {
            priceMatch = regex.Match(contentList1[i].Html);
            
        }

Initial URL
http://i49.tinypic.com/345nacp.jpg

Initial Description
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.

Initial Title
Ektron list based on taxonomy id

Initial Tags
regex, list, api

Initial Language
C#