示例#1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Item currentItem = Sitecore.Context.Item;
            PageSummaryItem item = new PageSummaryItem(currentItem);
            string canonicalTag = item.GetCanonicalTag();

            string metaDescription = item.GetMetaDescription();

            //Add page title //todo: add club name
            string title = Translate.Text("Virgin Active");
            string browserPageTitle = item.GetPageTitle();

            string section = Sitecore.Web.WebUtil.GetQueryString("section");

            if (!String.IsNullOrEmpty(section))
            {
                PageSummaryItem listing = null;
                if (currentItem.TemplateID.ToString() == ClassesListingItem.TemplateId)
                {
                    //Get classes listing browser page title
                    listing = Sitecore.Context.Database.GetItem(ItemPaths.SharedClasses + "/" + section);
                }
                else if (currentItem.TemplateID.ToString() == FacilitiesListingItem.TemplateId)
                {
                    //Get facility listing browser page title
                    listing = Sitecore.Context.Database.GetItem(ItemPaths.SharedFacilities + "/" + section);
                }

                if (listing != null)
                {
                    browserPageTitle = listing.GetPageTitle();
                    canonicalTag = String.IsNullOrEmpty(Request.QueryString["section"]) ? listing.GetCanonicalTag() : listing.GetCanonicalTag(Request.QueryString["section"]);
                    metaDescription = listing.GetMetaDescription();
                }
            }

            if (!String.IsNullOrEmpty(browserPageTitle))
            {
                title = String.Format("{0} | {1}", browserPageTitle, title);
            }

            Page.Title = title;
            //Add canonical
            Page.Header.Controls.Add(new Literal() { Text = canonicalTag });
            //Add meta description
            Page.Header.Controls.Add(new Literal() { Text = metaDescription });
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            //THIS IS WHERE WE HIDE/SHOW COOKIE MESSAGE -N.B. User Session initialised and set in Header

            //Interorgate the request 'Do Not Track' settings.
            HttpContext objContext = HttpContext.Current;
            bool headerDoNotTrack = false;

            if (!string.IsNullOrEmpty(objContext.Request.Headers["DNT"]))
            {
                headerDoNotTrack = objContext.Request.Headers["DNT"] == "1" ? true : false;
            }

            User objUser = new User();

            //READ/SET COOKIE OPTIONS
            if (Session["sess_User"] == null)
            {
                newSession = true;
            }
            else
            {
                objUser = (User)Session["sess_User"];
            }

            //If this has not been set -we need to show the cookie message
            if (!headerDoNotTrack)
            {
                //Check if User Session object has been set -i.e. not first page load
                if (!newSession)
                {
                    //Have the cookie preferences been set?
                    if (objUser.Preferences == null)
                    {
                        //Show Cookie Preferences ribbon
                        CookieRibbon cookieDeclaration = Page.LoadControl("~/layouts/virginactive/CookieRibbon.ascx") as CookieRibbon;
                        RibbonPh.Controls.Add(cookieDeclaration);

                        string classNames = BodyTag.Attributes["class"] != null ? BodyTag.Attributes["class"] : "";
                        BodyTag.Attributes.Add("class", classNames.Length > 0 ? classNames + " cookie-show" : "cookie-show");
                    }
                }
                else
                {
                    //Seesion info not set (as it's a new session) -Check the 'Cookie Preferences Cookie' exists
                    if (string.IsNullOrEmpty(CookieHelper.GetOptInCookieValue(CookieKeyNames.MarketingCookies)))
                    {
                        //User has NOT stored settings
                        //Show Cookie Preferences ribbon
                        CookieRibbon cookieDeclaration = Page.LoadControl("~/layouts/virginactive/CookieRibbon.ascx") as CookieRibbon;
                        RibbonPh.Controls.Add(cookieDeclaration);

                        string classNames = BodyTag.Attributes["class"] != null ? BodyTag.Attributes["class"] : "";
                        BodyTag.Attributes.Add("class", classNames.Length > 0 ? classNames + " cookie-show" : "cookie-show");
                    }
                }
            }

            //READ/SET COOKIE OPTIONS
            if (newSession)
            {
                //New Session

                //Check if cookie preferences session cookie exists
                if (!string.IsNullOrEmpty(CookieHelper.GetOptInCookieValue(CookieKeyNames.MarketingCookies)))
                {
                    Preferences preferences = new Preferences();

                    preferences.MarketingCookies = CookieHelper.GetOptInCookieValue(CookieKeyNames.MarketingCookies) == "Y" ? true : false;
                    preferences.MetricsCookies = CookieHelper.GetOptInCookieValue(CookieKeyNames.MetricsCookies) == "Y" ? true : false;
                    preferences.PersonalisedCookies = CookieHelper.GetOptInCookieValue(CookieKeyNames.PersonalisedCookies) == "Y" ? true : false;
                    preferences.SocialCookies = CookieHelper.GetOptInCookieValue(CookieKeyNames.SocialCookies) == "Y" ? true : false;

                    //Store to session
                    objUser.Preferences = preferences;
                }
                else
                {
                    if (headerDoNotTrack)
                    {
                        //Set Preferences in User Session -default to N
                        Preferences preferences = new Preferences();

                        preferences.MarketingCookies = false;
                        preferences.MetricsCookies = false;
                        preferences.PersonalisedCookies = false;
                        preferences.SocialCookies = false;

                        objUser.Preferences = preferences;

                        //Set Cookie Preferences Cookie
                        CookieHelper.AddUpdateOptInCookie(CookieKeyNames.MarketingCookies, "N");
                        CookieHelper.AddUpdateOptInCookie(CookieKeyNames.MetricsCookies, "N");
                        CookieHelper.AddUpdateOptInCookie(CookieKeyNames.PersonalisedCookies, "N");
                        CookieHelper.AddUpdateOptInCookie(CookieKeyNames.SocialCookies, "N");

                        //Delete Existing Personalisation Cookie
                        CookieHelper.DeleteCookie();
                    }
                }
            }

            //DEFAULT PREFERENCES IF NOT SET
            if (objUser.Preferences == null)
            {
                //Set preferences in User Session -default to Y
                Preferences preferences = new Preferences();

                preferences.MarketingCookies = true;
                preferences.MetricsCookies = true;
                preferences.PersonalisedCookies = true;
                preferences.SocialCookies = true;

                //Store to session
                objUser.Preferences = preferences;

                //Set Cookie Preferences Cookie -default to permission allowed
                CookieHelper.AddUpdateOptInCookie(CookieKeyNames.MarketingCookies, "Y");
                CookieHelper.AddUpdateOptInCookie(CookieKeyNames.MetricsCookies, "Y");
                CookieHelper.AddUpdateOptInCookie(CookieKeyNames.PersonalisedCookies, "Y");
                CookieHelper.AddUpdateOptInCookie(CookieKeyNames.SocialCookies, "Y");
            }

            //Save session
            Session["sess_User"] = objUser;

            CampaignItem cmp = new CampaignItem(Sitecore.Context.Item);

            if (!String.IsNullOrEmpty(cmp.CampaignBase.Termsandconditionslink.Raw))
            {
                privacy = new PageSummaryItem(cmp.CampaignBase.Termsandconditionslink.Item);
            }

            Item currentItem = Sitecore.Context.Item;
            PageSummaryItem item = new PageSummaryItem(currentItem);
            string canonicalTag = item.GetCanonicalTag();

            string metaDescription = item.GetMetaDescription();

            //Add page title //todo: add club name
            string title = Translate.Text("Virgin Active");
            string browserPageTitle = item.GetPageTitle();

            string section = Sitecore.Web.WebUtil.GetQueryString("section");

            if (!String.IsNullOrEmpty(section))
            {
                PageSummaryItem listing = null;
                if (currentItem.TemplateID.ToString() == ClassesListingItem.TemplateId)
                {
                    //Get classes listing browser page title
                    listing = Sitecore.Context.Database.GetItem(ItemPaths.SharedClasses + "/" + section);
                }
                else if (currentItem.TemplateID.ToString() == FacilitiesListingItem.TemplateId)
                {
                    //Get facility listing browser page title
                    listing = Sitecore.Context.Database.GetItem(ItemPaths.SharedFacilities + "/" + section);
                }

                if (listing != null)
                {
                    browserPageTitle = listing.GetPageTitle();
                    canonicalTag = String.IsNullOrEmpty(Request.QueryString["section"]) ? listing.GetCanonicalTag() : listing.GetCanonicalTag(Request.QueryString["section"]);
                    metaDescription = listing.GetMetaDescription();
                }
            }

            if (!String.IsNullOrEmpty(browserPageTitle))
            {
                title = String.Format("{0} | {1}", browserPageTitle, title);
            }

            Page.Title = title;
            //Add canonical
            Page.Header.Controls.Add(new Literal() { Text = canonicalTag });
            //Add meta description
            Page.Header.Controls.Add(new Literal() { Text = metaDescription });

            //Load OpenTag container -depending on cookie preferences

            if (!newSession)
            {
                //Add dynamic content to header
                HtmlHead head = (HtmlHead)Page.Header;

                if (objUser.Preferences != null)
                {
                    if (objUser.Preferences.MarketingCookies && objUser.Preferences.MetricsCookies)
                    {
                        //Have permission to load in OpenTag
                        head.Controls.Add(new LiteralControl(OpenTagHelper.OpenTagVirginActiveUK));
                    }
                }

                //LOAD IN SOCIAL OPEN GRAPH -if cookie preference allows

            }

            //Get club details
            if (!Page.IsPostBack)
            {
                Item landingItem =
                    Sitecore.Context.Item.Axes.SelectSingleItem(String.Format("ancestor-or-self::*[@@tid='{0}']",
                                                                              ClubMicrositeLandingItem.TemplateId));

                if (landingItem == null)
                {
                    return;
                }

                ClubMicrositeLandingItem club = new ClubMicrositeLandingItem(landingItem);

                ClubItem linkClub = new ClubItem(club.Club.Item);
            }
        }
        private void SetPage()
        {
            //Check Session
            if (Session["sess_User_landing"] == null)
            {
                newSession = true;
            }

            //THIS IS WHERE WE HIDE/SHOW COOKIE MESSAGE -N.B. User Session initialised and set in Header

            //Interorgate the request 'Do Not Track' settings.
            HttpContext objContext = HttpContext.Current;
            bool headerDoNotTrack = false;

            if (!string.IsNullOrEmpty(objContext.Request.Headers["DNT"]))
            {
                headerDoNotTrack = objContext.Request.Headers["DNT"] == "1" ? true : false;
            }

            //If this has not been set -we need to show the cookie message
            if (!headerDoNotTrack)
            {
                //Check if User Session object has been set -i.e. not first page load
                if (!newSession)
                {
                    User objUser = new User();

                    objUser = (User)Session["sess_User_landing"];

                    //Have the cookie preferences been set?
                    if (objUser.Preferences == null)
                    {
                        //Show Cookie Preferences ribbon
                        CookieRibbon cookieDeclaration = Page.LoadControl("~/layouts/virginactive/CookieRibbon.ascx") as CookieRibbon;
                        RibbonPh.Controls.Add(cookieDeclaration);

                        Control HeaderRegion = (Control)Page.FindControl("HeaderRegion");
                        if (HeaderRegion != null && HeaderRegion.Controls.Count > 0)
                        {
                            Control HeaderControlContainer = HeaderRegion.Controls[0];
                            if (HeaderControlContainer != null && HeaderControlContainer.Controls.Count > 0)
                            {
                                Control HeaderControl = HeaderControlContainer.Controls[0];
                                if (HeaderControl != null)
                                {
                                    //HtmlGenericControl HeaderContainer =
                                    //    (HtmlGenericControl)HeaderControl.FindControl("HeaderContainer");
                                    //HtmlGenericControl ShowMorePanel =
                                    //    (HtmlGenericControl)HeaderControl.FindControl("ShowMore");

                                    string classNames = BodyTag.Attributes["class"] != null
                                                            ? BodyTag.Attributes["class"]
                                                            : "";
                                    BodyTag.Attributes.Add("class",
                                                           classNames.Length > 0
                                                               ? classNames + " cookie-show"
                                                               : "cookie-show");

                                    //ShowMorePanel.Attributes.Add("style", "display:none;");
                                }
                            }
                        }
                    }
                }
                else
                {
                    //Session info not set (as it's a new session) -Check the 'Cookie Preferences Cookie' exists
                    if (string.IsNullOrEmpty(CookieHelper.GetOptInCookieValue(CookieKeyNames.MarketingCookies)))
                    {
                        //User has NOT stored settings
                        //Show Cookie Preferences ribbon
                        CookieRibbon cookieDeclaration = Page.LoadControl("~/layouts/virginactive/CookieRibbon.ascx") as CookieRibbon;
                        RibbonPh.Controls.Add(cookieDeclaration);

                        string classNames = BodyTag.Attributes["class"] != null
                                                ? BodyTag.Attributes["class"]
                                                : "";
                        BodyTag.Attributes.Add("class",
                                                classNames.Length > 0
                                                    ? classNames + " cookie-show"
                                                    : "cookie-show");
                    }
                }

            }

            PageSummaryItem item = new PageSummaryItem(currentItem);

            string canonicalTag = item.GetCanonicalTag();

            string metaDescription = item.GetMetaDescription();

            //Add page title //todo: add club name
            string title = Translate.Text("Virgin Active");
            string browserPageTitle = item.GetPageTitle();

            if (!String.IsNullOrEmpty(browserPageTitle))
            {
                title = String.Format("{0} | {1}", browserPageTitle, title);
            }

            Page.Title = browserPageTitle;

            //Add canonical
            Page.Header.Controls.Add(new Literal() { Text = canonicalTag });
            //Add meta description
            Page.Header.Controls.Add(new Literal() { Text = metaDescription });

            //Load OpenTag container for all pages (Google needs it)

            HtmlHead head = (HtmlHead)Page.Header;
            head.Controls.Add(new LiteralControl(OpenTagHelper.OpenTagVirginActiveUK));

            //Add open graph tags (controls info facebook needs)
            string openGraphDescription = "";
            string openGraphImage = "";
            string openGraphTitle = title;

            openGraphDescription = SitecoreHelper.GetSiteSetting("Facebook description");
            openGraphImage = SitecoreHelper.GetSiteSetting("Facebook image url");

            //Overwrite if we are inheriting from Social Open Graph
            SocialOpenGraphItem openGraphDetails;
            var itemTemplate = TemplateManager.GetTemplate(currentItem);

            if (itemTemplate.InheritsFrom("Social Open Graph"))
            {
                openGraphDetails = (SocialOpenGraphItem)currentItem.InnerItem;

                openGraphTitle = openGraphDetails.Title.Raw != "" ? openGraphDetails.Title.Raw : openGraphTitle;
                openGraphDescription = openGraphDetails.Description.Raw != "" ? openGraphDetails.Description.Raw : openGraphDescription;
                openGraphImage = openGraphDetails.ImageUrl.Raw != "" ? openGraphDetails.ImageUrl.Raw : openGraphImage;
            }

            Literal openGraphMeta = new Literal();
            openGraphMeta.Text = String.Format(metaProperty, "og:title", openGraphTitle);
            openGraphMeta.Text += String.Format(metaProperty, "og:description", openGraphDescription);
            openGraphMeta.Text += String.Format(metaProperty, "og:image", openGraphImage);

            Page.Header.Controls.Add(openGraphMeta);

            //Add no-follow meta tags
            if (item.Noindex != null)
            {
                if (item.Noindex.Checked)
                {
                    Page.Header.Controls.Add(new LiteralControl(@"<meta name=""robots"" content=""noindex, follow"" />"));
                }
            }
        }
示例#4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //CREATE NEW USER SESSION
            //Check if we are loading home page for the first time
            User objUser = new User();

            //Check Session
            if (Session["sess_User"] == null)
            {
                newSession = true;
            }
            else
            {
                objUser = (User)Session["sess_User"];
            }

            //READ/SET COOKIE OPTIONS
            if (newSession)
            {
                //New Session

                //Check gallery preference
                if (!string.IsNullOrEmpty(CookieHelper.GetCookieValue(CookieKeyNames.ShowGallery)))
                {
                    //Store to session
                    objUser.ShowGallery = CookieHelper.GetCookieValue(CookieKeyNames.ShowGallery) == "Y" ? true : false;
                }

                //Check if cookie preferences session cookie exists
                if (!string.IsNullOrEmpty(CookieHelper.GetOptInCookieValue(CookieKeyNames.MarketingCookies)))
                {
                    Preferences preferences = new Preferences();

                    preferences.MarketingCookies = CookieHelper.GetOptInCookieValue(CookieKeyNames.MarketingCookies) == "Y" ? true : false;
                    preferences.MetricsCookies = CookieHelper.GetOptInCookieValue(CookieKeyNames.MetricsCookies) == "Y" ? true : false;
                    preferences.PersonalisedCookies = CookieHelper.GetOptInCookieValue(CookieKeyNames.PersonalisedCookies) == "Y" ? true : false;
                    preferences.SocialCookies = CookieHelper.GetOptInCookieValue(CookieKeyNames.SocialCookies) == "Y" ? true : false;

                    //Store to session
                    objUser.Preferences = preferences;
                }
                else
                {
                    //Interorgate the request 'Do Not Track' settings.
                    HttpContext objContext = HttpContext.Current;
                    bool headerDoNotTrack = false;

                    if (!string.IsNullOrEmpty(objContext.Request.Headers["DNT"]))
                    {
                        headerDoNotTrack = objContext.Request.Headers["DNT"] == "1" ? true : false;
                    }

                    if (headerDoNotTrack)
                    {
                        //Set Preferences in User Session -default to N
                        Preferences preferences = new Preferences();

                        preferences.MarketingCookies = false;
                        preferences.MetricsCookies = false;
                        preferences.PersonalisedCookies = false;
                        preferences.SocialCookies = false;

                        objUser.Preferences = preferences;

                        //Set Cookie Preferences Cookie
                        CookieHelper.AddUpdateOptInCookie(CookieKeyNames.MarketingCookies, "N");
                        CookieHelper.AddUpdateOptInCookie(CookieKeyNames.MetricsCookies, "N");
                        CookieHelper.AddUpdateOptInCookie(CookieKeyNames.PersonalisedCookies, "N");
                        CookieHelper.AddUpdateOptInCookie(CookieKeyNames.SocialCookies, "N");

                        //Delete Existing Personalisation Cookie
                        CookieHelper.DeleteCookie();
                    }
                }
            }

            //DEFAULT PREFERENCES
            if (objUser.Preferences == null)
            {
                //Set preferences in User Session -default to Y
                Preferences preferences = new Preferences();

                preferences.MarketingCookies = true;
                preferences.MetricsCookies = true;
                preferences.PersonalisedCookies = true;
                preferences.SocialCookies = true;

                //Store to session
                objUser.Preferences = preferences;

                //Set Cookie Preferences Cookie -default to permission allowed
                CookieHelper.AddUpdateOptInCookie(CookieKeyNames.MarketingCookies, "Y");
                CookieHelper.AddUpdateOptInCookie(CookieKeyNames.MetricsCookies, "Y");
                CookieHelper.AddUpdateOptInCookie(CookieKeyNames.PersonalisedCookies, "Y");
                CookieHelper.AddUpdateOptInCookie(CookieKeyNames.SocialCookies, "Y");
            }

            //SET PAGE META DATA
            PageSummaryItem item = new PageSummaryItem(currentItem);

            string canonicalTag = item.GetCanonicalTag();

            string metaDescription = item.GetMetaDescription();

            //Add page title //todo: add club name
            string title = Translate.Text("Virgin Active");
            string browserPageTitle = item.GetPageTitle();

            if (!String.IsNullOrEmpty(browserPageTitle))
            {
                title = String.Format("{0} | {1}", browserPageTitle, title);
            }

            Page.Title = title;
            //Add canonical
            Page.Header.Controls.Add(new Literal() { Text = canonicalTag });
            //Add meta description
            Page.Header.Controls.Add(new Literal() { Text = metaDescription });

            //Load OpenTag container for all pages (Google needs it)
            HtmlHead head = (HtmlHead)Page.Header;
            head.Controls.Add(new LiteralControl(OpenTagHelper.OpenTagVirginActiveUK));

            //Add open graph tags (controls info facebook needs)
            string openGraphDescription = "";
            string openGraphImage = "";
            string openGraphTitle = title;

            string startPath = Sitecore.Context.Site.StartPath.ToString();
            var homeItem = Sitecore.Context.Database.GetItem(startPath);
            var options = new UrlOptions { AlwaysIncludeServerUrl = true, AddAspxExtension = false, LanguageEmbedding = LanguageEmbedding.Never };
            var homeUrl = LinkManager.GetItemUrl(homeItem, options);
            var mediaOptions = new MediaUrlOptions { AbsolutePath = true };

            //Set return to main site link
            HomeMainSiteUrl = homeUrl + "?sc_device=default&persisted=true";

            openGraphDescription = SitecoreHelper.GetSiteSetting("Facebook description");
            openGraphImage = SitecoreHelper.GetSiteSetting("Facebook image url");

            //Overwrite if we are inheriting from Social Open Graph
            SocialOpenGraphItem openGraphDetails;
            var itemTemplate = TemplateManager.GetTemplate(currentItem);

            if (itemTemplate.InheritsFrom("Social Open Graph"))
            {
                openGraphDetails = (SocialOpenGraphItem)currentItem;

                openGraphTitle = openGraphDetails.Title.Raw != "" ? openGraphDetails.Title.Raw : openGraphTitle;
                openGraphDescription = openGraphDetails.Description.Raw != "" ? openGraphDetails.Description.Raw : openGraphDescription;
                openGraphImage = openGraphDetails.ImageUrl.Raw != "" ? openGraphDetails.ImageUrl.Raw : openGraphImage;
            }

            Literal openGraphMeta = new Literal();
            openGraphMeta.Text = String.Format(metaProperty, "og:title", openGraphTitle);
            openGraphMeta.Text = openGraphMeta.Text +  String.Format(metaProperty, "og:description", openGraphDescription);
            openGraphMeta.Text = openGraphMeta.Text + String.Format(metaProperty, "og:image", openGraphImage);

            Page.Header.Controls.Add(openGraphMeta);

            //SET PAGE LINKS

            youTubeUrl = Settings.YouTubeLinkUrl;
            twitterUrl = Settings.TwitterLinkUrl;
            facebookUrl = Settings.FacebookLinkUrl;

            privacyUrl = SitecoreHelper.GetQualifiedUrlFromItemPath(ItemPaths.PrivacyPolicy);
            termsAndConditionsUrl = SitecoreHelper.GetQualifiedUrlFromItemPath(ItemPaths.TermsAndConditions);
            cookiesUrl = SitecoreHelper.GetQualifiedUrlFromItemPath(ItemPaths.CookiesForm);

            //Set featured promo link and home page link
            Sitecore.Links.UrlOptions urlOptions = new Sitecore.Links.UrlOptions();
            urlOptions.AlwaysIncludeServerUrl = true;
            urlOptions.AddAspxExtension = true;
            urlOptions.LanguageEmbedding = LanguageEmbedding.Never;

            //Set home page link (set as club home if home club set)
            homeOrClubPageUrl = Sitecore.Links.LinkManager.GetItemUrl(homeItem, urlOptions);

            //<h1><a href="/" class="logo"><strong>VIRGIN ACTIVE</strong> HEALTH CLUBS</a></h1>
            System.Text.StringBuilder markupBuilder = new System.Text.StringBuilder();

            if (Sitecore.Context.Item.ID == homeItem.ID)
            {
                //Page is home page
                markupBuilder.Append(@"<h1><a class=""logo"" href=""");
                markupBuilder.Append(HomeOrClubPageUrl + @"""><strong class=""home"">");
                markupBuilder.Append(Translate.Text("VIRGIN ACTIVE") + "</strong> ");
                markupBuilder.Append(Translate.Text("HEALTH CLUBS") + "</a></h1>");
            }
            else
            {
                markupBuilder.Append(@"<a class=""logo"" href=""");
                markupBuilder.Append(HomeOrClubPageUrl + @"""><strong>");
                markupBuilder.Append(Translate.Text("VIRGIN ACTIVE") + "</strong> ");
                markupBuilder.Append(Translate.Text("HEALTH CLUBS") + "</a>");
            }

            ltrHeaderText.Text = markupBuilder.ToString();
        }
示例#5
0
        //protected string UKHost = String.Empty;
        protected void Page_Load(object sender, EventArgs e)
        {
            //Check details of each country
            List<CountryItem> lstCountries = new List<CountryItem>();

            lstCountries = currentItem.InnerItem.Axes.SelectItems(String.Format("descendant::*[@@tid='{0}']", CountryItem.TemplateId)).ToList().ConvertAll(Y => new CountryItem(Y));

            foreach (CountryItem country in lstCountries)
            {
                switch (country.InnerItem.Name)
                {
                    case "south-africa":
                        lnkSouthAfrica.Text = country.Name.Raw;
                        lnkSouthAfrica.NavigateUrl = country.Url.Raw;

                        if (country.InnerItem.HasChildren && country.Showclublist.Checked)
                        {
                            List<ClubLinkItem> clubs = country.InnerItem.Children.ToList().ConvertAll(x => new ClubLinkItem(x));

                            if (clubs != null && clubs.Count > 0)
                            {
                                clubs.First().IsFirst = true;
                                clubs.Last().IsLast = true;

                                ClubListSouthAfrica.DataSource = clubs;
                                ClubListSouthAfrica.DataBind();
                            }
                        }
                        else
                        {
                            clubsSouthAfrica.Visible = false;
                        }
                        break;
                    case "italy":
                        lnkItaly.Text = country.Name.Raw;
                        lnkItaly.NavigateUrl = country.Url.Raw;

                        if (country.InnerItem.HasChildren && country.Showclublist.Checked)
                        {
                            List<ClubLinkItem> clubs = country.InnerItem.Children.ToList().ConvertAll(x => new ClubLinkItem(x));

                            if (clubs != null && clubs.Count > 0)
                            {
                                clubs.First().IsFirst = true;
                                clubs.Last().IsLast = true;

                                ClubListItaly.DataSource = clubs;
                                ClubListItaly.DataBind();
                            }
                        }
                        else
                        {
                            clubsItaly.Visible = false;
                        }
                        break;
                    case "spain":
                        lnkSpain.Text = country.Name.Raw;
                        lnkSpain.NavigateUrl = country.Url.Raw;

                        if (country.InnerItem.HasChildren && country.Showclublist.Checked)
                        {
                            List<ClubLinkItem> clubs = country.InnerItem.Children.ToList().ConvertAll(x => new ClubLinkItem(x));

                            if (clubs != null && clubs.Count > 0)
                            {
                                clubs.First().IsFirst = true;
                                clubs.Last().IsLast = true;

                                ClubListSpain.DataSource = clubs;
                                ClubListSpain.DataBind();
                            }
                        }
                        else
                        {
                            clubsSpain.Visible = false;
                        }
                        break;
                    case "portugal":
                        lnkPortugal.Text = country.Name.Raw;
                        lnkPortugal.NavigateUrl = country.Url.Raw;

                        if (country.InnerItem.HasChildren && country.Showclublist.Checked)
                        {
                            List<ClubLinkItem> clubs = country.InnerItem.Children.ToList().ConvertAll(x => new ClubLinkItem(x));

                            if (clubs != null && clubs.Count > 0)
                            {
                                clubs.First().IsFirst = true;
                                clubs.Last().IsLast = true;

                                ClubListPortugal.DataSource = clubs;
                                ClubListPortugal.DataBind();
                            }
                        }
                        else
                        {
                            clubsPortugal.Visible = false;
                        }
                        break;
                    case "united-kingdom":
                        lnkUnitedKingdon.Text = country.Name.Raw;
                        lnkUnitedKingdon.NavigateUrl = country.Url.Raw;

                        //UKHost = country.Url.Raw;
                        //if (UKHost.EndsWith("/"))
                        //{
                        //    UKHost = UKHost.Remove(UKHost.Length - 1);
                        //}

                        if (country.Usemainclublist.Checked)
                        {
                            //Use the club items from main site clubs section

                            Item clubRoot = Sitecore.Context.Database.GetItem(ItemPaths.Clubs);

                            List<ClubItem> clubList = clubRoot.Children.ToList().ConvertAll(X => new ClubItem(X));

                            clubList.RemoveAll(x => x.IsHiddenFromMenu());
                            clubList.RemoveAll(x => x.IsPlaceholder.Checked && !x.ShowInClubSelect.Checked);

                            if (clubList != null && clubList.Count > 0 && country.Showclublist.Checked)
                            {
                                clubList.First().IsFirst = true;
                                clubList.Last().IsLast = true;

                                ClubListUK.DataSource = clubList;
                                ClubListUK.DataBind();
                            }
                            else
                            {
                                clubsUnitedKingdon.Visible = false;
                            }
                        }

                        break;
                    case "australia":
                        lnkAustralia.Text = country.Name.Raw;
                        lnkAustralia.NavigateUrl = country.Url.Raw;

                        if (country.InnerItem.HasChildren && country.Showclublist.Checked)
                        {
                            List<ClubLinkItem> clubs = country.InnerItem.Children.ToList().ConvertAll(x => new ClubLinkItem(x));

                            if (clubs != null && clubs.Count > 0)
                            {
                                clubs.First().IsFirst = true;
                                clubs.Last().IsLast = true;

                                ClubListAustralia.DataSource = clubs;
                                ClubListAustralia.DataBind();
                            }
                        }
                        else
                        {
                            clubsAustralia.Visible = false;
                        }
                        break;
                    default:
                        break;
                }
            }

            //Load all club lists.

            ////Save session
            //Session["sess_User"] = objUser;

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

            //if (objUser.Preferences.MarketingCookies && objUser.Preferences.MetricsCookies)
            //{
            //Have permission to load in OpenTag
            //head.Controls.Add(new LiteralControl(OpenTagHelper.OpenTagVirginActiveGroup));
            //}

            PageSummaryItem item = new PageSummaryItem(currentItem);

            string canonicalTag = item.GetCanonicalTag();

            string metaDescription = item.GetMetaDescription();

            //Add page title //todo: add club name
            string title = Translate.Text("Virgin Active");
            string browserPageTitle = item.GetPageTitle();

            string section = Sitecore.Web.WebUtil.GetQueryString("section");

            if (!String.IsNullOrEmpty(section))
            {
                PageSummaryItem listing = null;
                if (currentItem.InnerItem.TemplateID.ToString() == ClassesListingItem.TemplateId)
                {
                    //Get classes listing browser page title
                    listing = Sitecore.Context.Database.GetItem(ItemPaths.SharedClasses + "/" + section);
                }
                else if (currentItem.InnerItem.TemplateID.ToString() == FacilitiesListingItem.TemplateId)
                {
                    //Get facility listing browser page title
                    listing = Sitecore.Context.Database.GetItem(ItemPaths.SharedFacilities + "/" + section);
                }

                if (listing != null)
                {
                    browserPageTitle = listing.GetPageTitle();
                    canonicalTag = String.IsNullOrEmpty(Request.QueryString["section"]) ? listing.GetCanonicalTag() : listing.GetCanonicalTag(Request.QueryString["section"]);
                    metaDescription = listing.GetMetaDescription();
                }
            }
        }
示例#6
0
        //protected string homePageUrl = "";
        protected void Page_Load(object sender, EventArgs e)
        {
            //Set a css class for <body> tag if we are using homepage or in a classic club
            if (currentItem.TemplateID.ToString() == HomePageItem.TemplateId)
            {
                BodyTag.Attributes.Add("class", "home");
            }
            else
            {
                if (Sitecore.Context.Item.Axes.SelectSingleItem(String.Format(@"ancestor-or-self::*[@@tid=""{0}""]", ClassicClubItem.TemplateId)) != null)
                {
                    BodyTag.Attributes.Add("class", "classic");
                }
            }

            //Check Session
            if (Session["sess_User"] == null)
            {
                newSession = true;
            }

            //THIS IS WHERE WE HIDE/SHOW COOKIE MESSAGE -N.B. User Session initialised and set in Header

            //Interorgate the request 'Do Not Track' settings.
            HttpContext objContext = HttpContext.Current;
            bool headerDoNotTrack = false;

            if (!string.IsNullOrEmpty(objContext.Request.Headers["DNT"]))
            {
                headerDoNotTrack = objContext.Request.Headers["DNT"] == "1" ? true : false;
            }

            //If this has not been set -we need to show the cookie message
            if (!headerDoNotTrack)
            {
                //Check if User Session object has been set -i.e. not first page load
                if (!newSession)
                {
                    User objUser = new User();

                    objUser = (User)Session["sess_User"];

                    //Have the cookie preferences been set?
                    if (objUser.Preferences == null)
                    {
                        //Show Cookie Preferences ribbon
                        CookieRibbon cookieDeclaration = Page.LoadControl("~/layouts/virginactive/CookieRibbon.ascx") as CookieRibbon;
                        RibbonPh.Controls.Add(cookieDeclaration);

                        Control HeaderRegion = (Control)Page.FindControl("HeaderRegion");
                        if (HeaderRegion != null && HeaderRegion.Controls.Count > 0)
                        {
                            Control HeaderControlContainer = HeaderRegion.Controls[0];
                            if (HeaderControlContainer != null && HeaderControlContainer.Controls.Count > 0)
                            {
                                Control HeaderControl = HeaderControlContainer.Controls[0];
                                if (HeaderControl != null)
                                {
                                    HtmlGenericControl HeaderContainer =
                                        (HtmlGenericControl)HeaderControl.FindControl("HeaderContainer");
                                    HtmlGenericControl ShowMorePanel =
                                        (HtmlGenericControl)HeaderControl.FindControl("ShowMore");

                                    string classNames = BodyTag.Attributes["class"] != null
                                                            ? BodyTag.Attributes["class"]
                                                            : "";
                                    BodyTag.Attributes.Add("class",
                                                           classNames.Length > 0
                                                               ? classNames + " cookie-show"
                                                               : "cookie-show");

                                    ShowMorePanel.Attributes.Add("style", "display:none;");
                                }
                            }
                        }
                    }
                }
                else
                {
                    //Session info not set (as it's a new session) -Check the 'Cookie Preferences Cookie' exists
                    if (string.IsNullOrEmpty(CookieHelper.GetOptInCookieValue(CookieKeyNames.MarketingCookies)))
                    {
                        //User has NOT stored settings
                        //Show Cookie Preferences ribbon
                        CookieRibbon cookieDeclaration = Page.LoadControl("~/layouts/virginactive/CookieRibbon.ascx") as CookieRibbon;
                        RibbonPh.Controls.Add(cookieDeclaration);

                        Control HeaderRegion = (Control)Page.FindControl("HeaderRegion");
                        if (HeaderRegion != null && HeaderRegion.Controls.Count > 0)
                        {
                            Control HeaderControlContainer = HeaderRegion.Controls[0];
                            if (HeaderControlContainer != null && HeaderControlContainer.Controls.Count > 0)
                            {
                                Control HeaderControl = HeaderControlContainer.Controls[0];
                                if (HeaderControl != null)
                                {
                                    //HtmlGenericControl HeaderContainerPanel = (HtmlGenericControl)HeaderControl.FindControl("HeaderContainer");
                                    HtmlGenericControl ShowMorePanel =
                                        (HtmlGenericControl)HeaderControl.FindControl("ShowMore");

                                    string classNames = BodyTag.Attributes["class"] != null
                                                            ? BodyTag.Attributes["class"]
                                                            : "";
                                    BodyTag.Attributes.Add("class",
                                                           classNames.Length > 0
                                                               ? classNames + " cookie-show"
                                                               : "cookie-show");

                                    if (ShowMorePanel != null)
                                    {
                                        ShowMorePanel.Attributes.Add("style", "display:none;");
                                    }
                                }
                            }
                        }
                    }
                }
            }
            /*
            //handle 404 header
            if (currentItem.Name.Contains("404"))
            {
                Response.TrySkipIisCustomErrors = true;
                Response.StatusCode = 404;
                Response.StatusDescription = "Page not found";
            }*/

            PageSummaryItem item = new PageSummaryItem(currentItem);

            //Add Facebook Application ID
            //Get Facebook Settings
            //string facebookAppID = Sitecore.Configuration.Settings.GetSetting("Virgin.FacebookAppId");
            //Add Facebook Settings to Head tag
            //if (!String.IsNullOrEmpty(facebookAppID))
            //{
            //    String facebookMetaTag = @"<meta property=""fb:app_id"" content=""{0}"" />";
            //    facebookMetaTag = string.Format(facebookMetaTag, facebookAppID);
            //    Page.Header.Controls.Add(new LiteralControl(facebookMetaTag));
            //}

            string canonicalTag = item.GetCanonicalTag();

            string metaDescription = item.GetMetaDescription();

            //Add page title //todo: add club name
            string title = Translate.Text("Virgin Active");
            string browserPageTitle = item.GetPageTitle();

            string section = Sitecore.Web.WebUtil.GetQueryString("section");

            if (!String.IsNullOrEmpty(section))
            {
                PageSummaryItem listing = null;
                if (currentItem.TemplateID.ToString() == ClassesListingItem.TemplateId)
                {
                    //Get classes listing browser page title
                    listing = Sitecore.Context.Database.GetItem(ItemPaths.SharedClasses + "/" + section);
                }
                else if (currentItem.TemplateID.ToString() == FacilitiesListingItem.TemplateId)
                {
                    //Get facility listing browser page title
                    listing = Sitecore.Context.Database.GetItem(ItemPaths.SharedFacilities + "/" + section);
                }

                if (listing != null)
                {
                    browserPageTitle = listing.GetPageTitle();
                    canonicalTag = String.IsNullOrEmpty(Request.QueryString["section"]) ? listing.GetCanonicalTag() : listing.GetCanonicalTag(Request.QueryString["section"]);
                    metaDescription = listing.GetMetaDescription();
                }
            }

            if (!String.IsNullOrEmpty(browserPageTitle))
            {
                title = String.Format("{0} | {1}", browserPageTitle, title);
            }

            Page.Title = title;
            //Add canonical
            Page.Header.Controls.Add(new Literal() { Text = canonicalTag });
            //Add meta description
            Page.Header.Controls.Add(new Literal() { Text = metaDescription });

            //Load OpenTag container for all pages (Google needs it)

            HtmlHead head = (HtmlHead)Page.Header;
            head.Controls.Add(new LiteralControl(OpenTagHelper.OpenTagVirginActiveUK));

            //Add open graph tags (controls info facebook needs)
            string openGraphDescription = "";
            string openGraphImage = "";
            string openGraphTitle = title;

            string startPath = Sitecore.Context.Site.StartPath.ToString();
            var homeItem = Sitecore.Context.Database.GetItem(startPath);
            var options = new UrlOptions { AlwaysIncludeServerUrl = true, AddAspxExtension = false, LanguageEmbedding = LanguageEmbedding.Never };
            var homeUrl = LinkManager.GetItemUrl(homeItem, options);
            var mediaOptions = new MediaUrlOptions { AbsolutePath = true };

            switch (item.InnerItem.TemplateName)
            {
                case Templates.YourHealthArticle:
                    YourHealthArticleItem yourHealthArticle = (YourHealthArticleItem)item.InnerItem;
                    openGraphDescription = yourHealthArticle.Articleteaser.Rendered != "" ? yourHealthArticle.Articleteaser.Rendered : SitecoreHelper.GetSiteSetting("Facebook description");
                    openGraphImage = yourHealthArticle.Articleimage.MediaItem != null ? homeUrl + yourHealthArticle.Articleimage.MediaUrl : SitecoreHelper.GetSiteSetting("Facebook image url");
                    break;
                case Templates.BlogEntry:
                    BlogEntryItem blogEntry = (BlogEntryItem)item.InnerItem;
                    openGraphDescription = blogEntry.Introduction.Rendered != "" ? blogEntry.Introduction.Rendered : SitecoreHelper.GetSiteSetting("Facebook description");
                    openGraphImage = blogEntry.Image.MediaItem != null ? homeUrl + blogEntry.Image.MediaUrl : SitecoreHelper.GetSiteSetting("Facebook image url");
                    break;
                case Templates.IndoorHistory:
                                //IndoorHistoryItem indoorHistoryItem = (IndoorHistoryItem)item.InnerItem;
                                //openGraphDescription = indoorHistoryItem.Subheading.Rendered != "" ? indoorHistoryItem.Subheading.Rendered : SitecoreHelper.GetSiteSetting("Facebook description");
                                //openGraphImage = indoorHistoryItem.Image.MediaItem != null ? homeUrl + indoorHistoryItem.Image.MediaUrl : SitecoreHelper.GetSiteSetting("Facebook image url");
                                //break;
                default:
                    openGraphDescription = SitecoreHelper.GetSiteSetting("Facebook description");
                    openGraphImage = SitecoreHelper.GetSiteSetting("Facebook image url");
                    break;
            }

            //Overwrite if we are inheriting from Social Open Graph
            SocialOpenGraphItem openGraphDetails;
            var itemTemplate = TemplateManager.GetTemplate(currentItem);

            if (itemTemplate.InheritsFrom("Social Open Graph"))
            {
                openGraphDetails = (SocialOpenGraphItem)currentItem;

                openGraphTitle = openGraphDetails.Title.Raw != "" ? openGraphDetails.Title.Raw : openGraphTitle;
                openGraphDescription = openGraphDetails.Description.Raw != "" ? openGraphDetails.Description.Raw : openGraphDescription;
                openGraphImage = openGraphDetails.ImageUrl.Raw != "" ? openGraphDetails.ImageUrl.Raw : openGraphImage;
            }

            Literal openGraphMeta = new Literal();
            openGraphMeta.Text = String.Format(metaProperty, "og:title", openGraphTitle);
            openGraphMeta.Text += String.Format(metaProperty, "og:description", openGraphDescription);
            openGraphMeta.Text += String.Format(metaProperty, "og:image", openGraphImage);

            Page.Header.Controls.Add(openGraphMeta);

            //if (!newSession)
            //{
            //    User objUser = (User)Session["sess_User"];
            //    //Add dynamic content to header
            //    HtmlHead head = (HtmlHead)Page.Header;

            //    if (objUser.Preferences != null)
            //    {
            //        if (objUser.Preferences.MarketingCookies && objUser.Preferences.MetricsCookies)
            //        {
            //            //Have permission to load in OpenTag
            //            head.Controls.Add(new LiteralControl(OpenTagHelper.OpenTagVirginActiveUK));
            //        }

            //        //Add Social
            //        if (objUser.Preferences.SocialCookies)
            //        {
            //            //Add open graph tags (controls info facebook needs)
            //            string openGraphDescription = "";
            //            string openGraphImage = "";
            //            string openGraphTitle = title;

            //            string startPath = Sitecore.Context.Site.StartPath.ToString();
            //            var homeItem = Sitecore.Context.Database.GetItem(startPath);
            //            var options = new UrlOptions { AlwaysIncludeServerUrl = true, AddAspxExtension = false, LanguageEmbedding = LanguageEmbedding.Never};
            //            var homeUrl = LinkManager.GetItemUrl(homeItem, options);
            //            var mediaOptions = new MediaUrlOptions { AbsolutePath = true };

            //            switch (item.InnerItem.TemplateName)
            //            {
            //                case Templates.YourHealthArticle:
            //                    YourHealthArticleItem yourHealthArticle = (YourHealthArticleItem)item.InnerItem;
            //                    openGraphDescription = yourHealthArticle.Articleteaser.Rendered != "" ? yourHealthArticle.Articleteaser.Rendered : SitecoreHelper.GetSiteSetting("Facebook description");
            //                    openGraphImage = yourHealthArticle.Articleimage.MediaItem != null ? homeUrl + yourHealthArticle.Articleimage.MediaUrl : SitecoreHelper.GetSiteSetting("Facebook image url");
            //                    break;
            //                case Templates.BlogEntry:
            //                    BlogEntryItem blogEntry = (BlogEntryItem)item.InnerItem;
            //                    openGraphDescription = blogEntry.Introduction.Rendered != "" ? blogEntry.Introduction.Rendered : SitecoreHelper.GetSiteSetting("Facebook description");
            //                    openGraphImage = blogEntry.Image.MediaItem != null ? homeUrl + blogEntry.Image.MediaUrl : SitecoreHelper.GetSiteSetting("Facebook image url");
            //                    break;
            //                case Templates.IndoorHistory:
            //                    IndoorHistoryItem indoorHistoryItem = (IndoorHistoryItem)item.InnerItem;
            //                    openGraphDescription = indoorHistoryItem.Subheading.Rendered != "" ? indoorHistoryItem.Subheading.Rendered : SitecoreHelper.GetSiteSetting("Facebook description");
            //                    openGraphImage = indoorHistoryItem.Image.MediaItem != null ? homeUrl + indoorHistoryItem.Image.MediaUrl : SitecoreHelper.GetSiteSetting("Facebook image url");
            //                    break;
            //                default:
            //                    openGraphDescription = SitecoreHelper.GetSiteSetting("Facebook description");
            //                    openGraphImage = SitecoreHelper.GetSiteSetting("Facebook image url");
            //                    break;
            //            }

            //            //Overwrite if we are inheriting from Social Open Graph
            //            SocialOpenGraphItem openGraphDetails;
            //            var itemTemplate = TemplateManager.GetTemplate(currentItem);

            //            if (itemTemplate.InheritsFrom("Social Open Graph"))
            //            {
            //                openGraphDetails = (SocialOpenGraphItem)currentItem;

            //                openGraphTitle = openGraphDetails.Title.Raw != "" ? openGraphDetails.Title.Raw : openGraphTitle;
            //                openGraphDescription = openGraphDetails.Description.Raw != "" ? openGraphDetails.Description.Raw : openGraphDescription;
            //                openGraphImage = openGraphDetails.ImageUrl.Raw != "" ? openGraphDetails.ImageUrl.Raw : openGraphImage;
            //            }

            //            Literal openGraphMeta = new Literal();
            //            openGraphMeta.Text = String.Format(metaProperty, "og:title", openGraphTitle);
            //            openGraphMeta.Text += String.Format(metaProperty, "og:description", openGraphDescription);
            //            openGraphMeta.Text += String.Format(metaProperty, "og:image", openGraphImage);

            //            if (item.InnerItem.TemplateName != Templates.BlogHome && item.InnerItem.TemplateName != Templates.YourHealthLanding && item.InnerItem.TemplateName != Templates.YourHealthListing)
            //            {
            //                //Add the open graph meta info (Do not want this on the listing pages as want to force facebook to index the detail pages)
            //                Page.Header.Controls.Add(openGraphMeta);
            //            }
            //        }
            //    }
            //}

            ////Add canonical
            //if (item != null)
            //{
            //    Literal canon = new Literal();
            //    canon.Text = String.Format(canonicalTag, item.QualifiedUrl);
            //    Page.Header.Controls.Add(canon);
            //}

            ////Add description meta tags.
            //if (!String.IsNullOrEmpty(item.Pagedescription.Raw))
            //{
            //    Literal meta = new Literal();
            //    meta.Text = String.Format(metaTag, "description", item.Pagedescription.Raw);
            //    Page.Header.Controls.Add(meta);
            //}

            //Add no-follow meta tags
            if (item.Noindex != null)
            {
                if (item.Noindex.Checked)
                {
                    Page.Header.Controls.Add(new LiteralControl(@"<meta name=""robots"" content=""noindex, follow"" />"));
                }
            }

            //Add Versioned Style Sheet
            System.Text.StringBuilder markupBuilder = new System.Text.StringBuilder();
            markupBuilder.Append(@"<link rel='stylesheet' href='/virginactive/css/style.css?ver=" + Settings.DeploymentVersionNumber + "' />");
            markupBuilder.Append(@"<link rel='stylesheet' href='/virginactive/css/fonts.css?ver=" + Settings.DeploymentVersionNumber + "' />");
            markupBuilder.Append(@"<link rel='stylesheet' href='/virginactive/css/cookies.css?ver=" + Settings.DeploymentVersionNumber + "' />");
            Page.Header.Controls.Add(new LiteralControl(markupBuilder.ToString()));

            //Add Scripts
            Control scriptPh = this.Page.FindControl("ScriptPh");
            if (scriptPh != null)
            {
                scriptPh.Controls.Add(new LiteralControl(@"
                    <script src='/virginactive/scripts/plugins.js?ver=" + Settings.DeploymentVersionNumber + @"'></script>
                    <script src='/virginactive/scripts/jquery.virgin.init.js?ver=" + Settings.DeploymentVersionNumber + @"'></script>
                    <script src='/virginactive/scripts/home.js'></script>
                    <script src='/virginactive/scripts/sitecore/jquery.virgin.ajax.js?ver=" + Settings.DeploymentVersionNumber + @"'></script>
                    <script src='/virginactive/scripts/sitecore/jquery.virginsearch.ajax.js?ver=" + Settings.DeploymentVersionNumber + @"'></script>
                    <script src='/virginactive/scripts/sitecore/VirginActiveHelper.js?ver=" + Settings.DeploymentVersionNumber + @"'></script>
                    <script src='/virginactive/scripts/sitecore/validation.js?ver=" + Settings.DeploymentVersionNumber + @"'></script>
                   "));
            }
        }