Exemplo n.º 1
0
        protected void blogArticlesGet()
        {
            blogItem = Sitecore.Context.Database.GetItem(ItemPaths.YourHealthBlog);

            if (blogItem != null)
            {
                if (blogItem.InnerItem.HasChildren)
                {
                    List<BlogEntryItem> blogPosts = new List<BlogEntryItem>();
                    blogPosts = blogItem.InnerItem.Axes.SelectItems(String.Format(@"descendant::*[@@tid=""{0}""]", BlogEntryItem.TemplateId.ToString())).ToList().ConvertAll(X => new BlogEntryItem(X));
                    blogPosts.Sort((x, y) => y.Created.CompareTo(x.Created));

                    //Check if a blog article has been selected on the page
                    List<Item> blogItemList = currentItem.BlogPost.ListItems.ToList();

                    if (blogItemList.Count > 0)
                    {

                        foreach (Item blog in blogItemList)
                        {

                            if (blog.TemplateID.ToString().Equals(BlogEntryItem.TemplateId))
                            {
                                blogEntry = blog;
                            }
                            break;
                        }
                    }
                    else //get most recent article
                    {
                        foreach (Item blog in blogPosts)
                        {

                            if (blog.TemplateID.ToString().Equals(BlogEntryItem.TemplateId))
                            {
                                blogEntry = blog;
                            }
                            break;
                        }

                    }

                    //Latest articles link list
                    int counter = 0;
                    string links = String.Empty;
                    foreach(BlogEntryItem blogLink in blogPosts.Where(x => x.ID != blogEntry.ID).Take(5))
                    {
                        counter++;

                        if (counter == 5 || counter == blogPosts.Count)
                        {
                            links += String.Format("<li class=\"last\"><a href=\"{0}\">{1}</a></li>", blogLink.Url, blogLink.Title.Raw);
                        }
                        else
                        {
                            links += String.Format("<li><a href=\"{0}\">{1}</a></li>", blogLink.Url, blogLink.Title.Raw);
                        }

                    }

                    LitLinks.Text = links;

                    //Create tag links
                     string blogUrl = LinkManager.GetItemUrl(blogItem);

                    for (int i = 0; i < blogEntry.TagsSplit.Count(); i++)
                    {

                        LitTags.Text = String.Format("<li><a href=\"{0}?tag={1}\">{1}</a> </li>", blogUrl, blogEntry.TagsSplit[i]);
                    }
                }

            }
        }
Exemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            privacyPolicyUrl = SitecoreHelper.GetQualifiedUrlFromItemPath(ItemPaths.PrivacyPolicy);
            //termsConditionsUrl = new PageSummaryItem(campaign.CampaignBase.Termsandconditionslink.Item).QualifiedUrl;
            termsConditionsUrl = SitecoreHelper.GetQualifiedUrlFromItemPath(ItemPaths.TermsAndConditions);
            londonTriathlonUrl = campaign.CampaignBase.QualifiedUrl;
            clubFinderUrl = new PageSummaryItem(Sitecore.Context.Database.GetItem(ItemPaths.ClubFinder)).QualifiedUrl;

            //add the item specific css stylesheet

            //Add dynamic content to header
            HtmlHead head = (HtmlHead)Page.Header;

            //Add Open Tag
            if (Session["sess_User"] != null)
            {
                User objUser = (User)Session["sess_User"];
                if (objUser.Preferences != null)
                {
                    if (objUser.Preferences.MarketingCookies && objUser.Preferences.MetricsCookies)
                    {
                        head.Controls.Add(new LiteralControl(OpenTagHelper.OpenTagVirginActiveUK));
                    }
                }
            }

            //Add Page Title
            //System.Text.StringBuilder markupBuilder = new System.Text.StringBuilder();

            //Get blog content to display in page
            List<Item> itemList = campaign.InnerItem.Children.ToList();

            foreach (Item item in itemList)
            {
                campaignBlogEntry = (BlogEntryItem)item;

                break;
            }

            //Get blog entry or article entry to link to (show first article only)
            itemList = campaign.CampaignBase.Blogarticles.ListItems.ToList();

            foreach (Item item in itemList)
            {
                linkedBlogEntry = (PageSummaryItem)item;
                break;
            }

            //Add Page Title
            System.Text.StringBuilder markupBuilder = new System.Text.StringBuilder();

            //HtmlTitle title = (HtmlTitle)Page.FindControl("title");
            //title.Text = "Virgin Active London Triathlon 2012 | The Official Virgin Active Site for Training Programmes, Event Information and More.";
            //markupBuilder.Append(@"<meta name='description' content='As the title sponsor of this great event for the 2nd year running, we are here to help first timers and old hats alike, every step of the way with training plans, event information and all the encouragement you will need to complete the Virgin Active London Triathlon.'>");
            markupBuilder.Append(@"<meta name='viewport' content='width=1020'>");
            markupBuilder.Append(@"<link rel='apple-touch-icon' href='/virginactive/images/apple-touch-icon.png'>");
            markupBuilder.Append(@"<link rel='shortcut icon' href='/virginactive/images/favicon.ico'>");
            markupBuilder.Append(@"<link href='/va_campaigns/Bespoke/LondonTriathlonII/css/styles.css' rel='stylesheet' type='text/css' media='screen' />");
            head.Controls.Add(new LiteralControl(markupBuilder.ToString()));

            Control scriptPh = this.Page.FindControl("ScriptPh");
            if (scriptPh != null)
            {
                scriptPh.Controls.Add(new LiteralControl(@"
                    <script src='/va_campaigns/Bespoke/LondonTriathlonII/js/plugins.js' type='text/javascript'></script>
                    <script src='/va_campaigns/Bespoke/LondonTriathlonII/js/scripts.js' type='text/javascript'></script>
                   "));
            }
        }
Exemplo n.º 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            privacyPolicyUrl = SitecoreHelper.GetQualifiedUrlFromItemPath(ItemPaths.PrivacyPolicy);
            //termsConditionsUrl = new PageSummaryItem(campaign.CampaignBase.Termsandconditionslink.Item).QualifiedUrl;
            termsConditionsUrl = SitecoreHelper.GetQualifiedUrlFromItemPath(ItemPaths.TermsAndConditions);
            clubFinderUrl = new PageSummaryItem(Sitecore.Context.Database.GetItem(ItemPaths.ClubFinder)).QualifiedUrl;
            eventPageUrl = new PageSummaryItem(Sitecore.Context.Database.GetItem(ItemPaths.TriathlonEventPage)).QualifiedUrl;

            //Get blog content to display in page
            //List<Item> itemList = campaign.InnerItem.Children.ToList();

            //foreach (Item item in itemList)
            //{
            //    campaignBlogEntry = (BlogEntryItem)item;
            //    break;
            //}

            string[] sectionMicrositeIds = ItemPaths.MicrositeSectionTemplates.Split('|');

            if (campaign.InnerItem.HasChildren)
            {
                //Check if we have child sections (by seeing if the item inherits the abstract template)

                if (sectionMicrositeIds.Count() > 0)
                {

                    StringBuilder query = new StringBuilder();
                    query.Append("child::*[");

                    foreach (string sectionTemplateId in sectionMicrositeIds)
                    {
                        query.Append(String.Format("@@tid='{0}' or ", sectionTemplateId));
                    }
                    query.Remove(query.Length - 4, 4);
                    query.Append("]");

                    //Check if we have child sections to show (by seeing if the item inherits the abstract template)
                    if (campaign.InnerItem.Axes.SelectItems(query.ToString()) != null)
                    {
                        List<PageSummaryItem> childSectionList = campaign.InnerItem.Axes.SelectItems(query.ToString()).ToList().ConvertAll(X => new PageSummaryItem(X));
                        childSectionList.RemoveAll(x => x.Hidefrommenu.Checked);

                        List<AbstractItem> sectionList = new List<AbstractItem>();
                        //grab first two child sections only
                        int i = 0;
                        foreach(PageSummaryItem childSection in childSectionList)
                        {
                            if (i < 2)
                            {
                                //Convert To Abstract Item
                                sectionList.Add((AbstractItem)childSection.InnerItem);
                            }
                            else
                            {
                                break;
                            }
                            i++;
                        }

                        sectionList.First().IsFirst = true;

                        if (sectionList.Count > 0)
                        {
                            ChildSectionListing.DataSource = sectionList;
                            ChildSectionListing.DataBind();
                        }
                    }

                    //Get blog entry item
                    if (campaign.InnerItem.Axes.SelectSingleItem(String.Format("child::*[@@tid='{0}']", BlogEntryItem.TemplateId)) != null)
                    {
                        campaignBlogEntry = (BlogEntryItem)campaign.InnerItem.Axes.SelectSingleItem(String.Format("child::*[@@tid='{0}']", BlogEntryItem.TemplateId));
                    }
                }
            }

            //Get blog entry or article entry to link to (show first article only)
            List<Item> linkedBlogItemList = campaign.CampaignBase.Blogarticles.ListItems.ToList();

            foreach (Item linkedBlogItem in linkedBlogItemList)
            {
                linkedBlogEntry = (PageSummaryItem)linkedBlogItem;
                break;
            }
        }