public List <PatternMatch> LoadPatterns() { List <PatternMatch> patternMatches = new List <PatternMatch>(); if (Tracker.IsActive) { if (SiteConfiguration.GetSiteSettingsItem() != null) { MultilistField profiles = SiteConfiguration.GetSiteSettingsItem().Fields["Visible Profiles"]; foreach (Item visibleProfile in profiles.GetItems()) { Item visibleProfileItem = Sitecore.Context.Database.GetItem(visibleProfile.ID); if (visibleProfileItem != null) { // show the pattern match if there is one. var userPattern = Tracker.Current.Interaction.Profiles[visibleProfileItem.Name]; if (userPattern != null) { // load the details about the matching pattern Item matchingPattern = Sitecore.Context.Database.GetItem(userPattern.PatternId.ToId()); if (matchingPattern != null) { Sitecore.Data.Items.MediaItem image = new Sitecore.Data.Items.MediaItem(((ImageField)matchingPattern.Fields["Image"]).MediaItem); string src = Sitecore.StringUtil.EnsurePrefix('/', Sitecore.Resources.Media.MediaManager.GetMediaUrl(image)); patternMatches.Add(new PatternMatch(visibleProfileItem["Name"], matchingPattern.Name, src)); } } } } } } return(patternMatches); }
protected void Page_Load(object sender, EventArgs e) { // load the labels from Sitecore if (!Page.IsPostBack) { litHeading.Text = GetDictionaryText("Register Heading"); lblName.Text = GetDictionaryText("Name"); lblEmail.Text = GetDictionaryText("Email"); lblPassword.Text = GetDictionaryText("Password"); lblConfirm.Text = GetDictionaryText("Confirm Password"); btnRegister.Text = GetDictionaryText("Register Button"); valName.Text = GetDictionaryText("Required"); valEmail.Text = GetDictionaryText("Required"); valPassword.Text = GetDictionaryText("Required"); valPasswordConfirm.Text = GetDictionaryText("Required"); valEmailFormat.Text = GetDictionaryText("Email is Not Valid"); } Item config = SiteConfiguration.GetSiteSettingsItem(); if (config["Allow Online Registration"] != "1") { txtName.Enabled = false; txtEmail.Enabled = false; txtPassword.Enabled = false; txtPasswordConfirm.Enabled = false; btnRegister.Enabled = false; lblMessage.Text = GetDictionaryText("Regisration is currently disabled for this site."); } }
private void Page_Load(object sender, EventArgs e) { ErrorHeading.Text = GetDictionaryText("Server Error in Application"); if (SiteConfiguration.GetSiteSettingsItem()["Show Error Details on Error Page"] == "1") { ExceptionMessageHeading.Text = GetDictionaryText("Message"); StackTraceHeading.Text = GetDictionaryText("Stack Trace"); InnerExceptionHeading.Text = GetDictionaryText("Inner Exception"); InnerExceptionMessageHeading.Text = GetDictionaryText("Message"); InnerStackTraceHeading.Text = GetDictionaryText("Stack Trace"); if (Session["LastException"] != null) { Exception exc = (Exception)Session["LastException"]; ExceptionMessage.Text = exc.Message; StackTrace.Text = exc.StackTrace.Replace("\r\n", "<br />"); if (exc.InnerException != null) { InnerExceptionPanel.Visible = true; InnerExceptionMessage.Text = exc.InnerException.Message; InnerStackTrace.Text = exc.InnerException.StackTrace.Replace("\r\n", "<br />"); } } } // Clear the error from the server Server.ClearError(); }
private void Page_Load(object sender, System.EventArgs e) { // This page is setting a lot fo the presentation details. This is due tot he flexible nature of this site. Item PresentationSettings = SiteConfiguration.GetPresentationSettingsItem(); // Set the page logo if (PresentationSettings["Logo Location"] == "Header") { Logo.Item = PresentationSettings; } else { Logo.Visible = false; logospan.Visible = false; tertiarynavspan.Attributes.Add("class", "span12"); } // set the page layout out_container.Attributes.Add("class", PresentationSettings["Layout Style"].ToLower().Replace(" ", "-")); // Show/Hide the top line if (PresentationSettings["Show Top Line"] != "1") { topline.Attributes.Add("class", "top_line_plain"); } // set the background image / color if (PresentationSettings["Background Image"] != string.Empty) { ImageField imgField = ((Sitecore.Data.Fields.ImageField)PresentationSettings.Fields["Background Image"]); mainbody.Style.Add("background-image", MediaManager.GetMediaUrl(imgField.MediaItem)); if (imgField.MediaItem.Parent.Key == "patterns") { mainbody.Attributes.Add("class", "background-pattern"); } else { mainbody.Attributes.Add("class", "background-cover"); } } else if (PresentationSettings["Background Color"] != string.Empty) { mainbody.Style.Add("background-color", PresentationSettings["Background Color"]); } Copyright.Item = SiteConfiguration.GetSiteSettingsItem(); }
private void Page_Load(object sender, EventArgs e) { Item siteSettings = SiteConfiguration.GetSiteSettingsItem(); Item home = SiteConfiguration.GetHomeItem(); Item currentItem = Sitecore.Context.Item; if (Sitecore.Context.Item.ID == home.ID || Sitecore.Context.Item.ParentID == home.ID) { pagetitle.Text = String.Format(siteSettings["Page Title for Home and Site Sections"], currentItem["Menu Title"]); } else { Item section = currentItem.Parent; while (section.ParentID != home.ID) { section = section.Parent; } pagetitle.Text = String.Format(siteSettings["Page Title for Lower Pages"], currentItem["Menu Title"], section["Menu Title"]); } }
public string PageTitle() { Item siteSettings = SiteConfiguration.GetSiteSettingsItem(); Item home = SiteConfiguration.GetHomeItem(); Item currentItem = Sitecore.Context.Item; if (Sitecore.Context.Item.ID == home.ID || Sitecore.Context.Item.ParentID == home.ID) { return(String.Format(siteSettings["Page Title for Home and Site Sections"], currentItem["Menu Title"])); } else { Item section = currentItem.Parent; while (section.ParentID != home.ID) { section = section.Parent; } return(String.Format(siteSettings["Page Title for Lower Pages"], currentItem["Menu Title"], section["Menu Title"])); } }
protected void FakeIPForLocalhost() { VisitorDataSet.VisitsRow currentVisit = Tracker.Visitor.GetCurrentVisit(); if (currentVisit != null) { // if we are local host. our IP is 127 which will not resolve so I am using a 'fake' ip address if (currentVisit.Ip[0] == 127) { currentVisit.Ip[0] = Convert.ToByte(SiteConfiguration.GetSiteSettingsItem()["IP1"]); currentVisit.Ip[1] = Convert.ToByte(SiteConfiguration.GetSiteSettingsItem()["IP2"]); currentVisit.Ip[2] = Convert.ToByte(SiteConfiguration.GetSiteSettingsItem()["IP3"]); currentVisit.Ip[3] = Convert.ToByte(SiteConfiguration.GetSiteSettingsItem()["IP4"]); // Sitecore may have already tried to resolve the 127 and failed, so this will initiate a retry currentVisit.HasGeoIpData = false; // Save our changes and let DMS request the GeoIP data again. currentVisit.UpdateGeoIpData(new TimeSpan(0, 0, 0, 0, 100)); currentVisit.AcceptChanges(); } } }
protected void FakeIPForLocalhost() { var ci = Tracker.Current.Interaction; if (ci != null) { // if we are local host. our IP is 127 which will not resolve so I am using a 'fake' ip address if (ci.Ip[0] == 127) { ci.Ip[0] = Convert.ToByte(SiteConfiguration.GetSiteSettingsItem()["IP1"]); ci.Ip[1] = Convert.ToByte(SiteConfiguration.GetSiteSettingsItem()["IP2"]); ci.Ip[2] = Convert.ToByte(SiteConfiguration.GetSiteSettingsItem()["IP3"]); ci.Ip[3] = Convert.ToByte(SiteConfiguration.GetSiteSettingsItem()["IP4"]); // Sitecore may have already tried to resolve the 127 and failed, so this will initiate a retry //ci.SetGeoData(null); // Save our changes and let DMS request the GeoIP data again. ci.UpdateGeoIpData(new TimeSpan(0, 0, 0, 0, 100)); ci.AcceptModifications(); } } }
private void Page_Load(object sender, EventArgs e) { if (!Sitecore.Context.PageMode.IsNormal) { WriteAlert("visit details are not available in page editor"); pnlDetails.Visible = false; } else { // throw an exception if DMS is not installed. if (!Sitecore.Analytics.Configuration.AnalyticsSettings.Enabled) { throw new ApplicationException("Launch Sitecore requires DMS to be installed."); } InitializeLabels(); FakeIPForLocalhost(); PageCount.Text = Convert.ToString(Tracker.CurrentVisit.VisitPageCount); EngagementValue.Text = Convert.ToString(Tracker.CurrentVisit.Value); // Populate the Patterns if (SiteConfiguration.GetSiteSettingsItem() != null) { MultilistField profiles = SiteConfiguration.GetSiteSettingsItem().Fields["Visible Profiles"]; rptPatternList.DataSource = profiles.GetItems(); rptPatternList.DataBind(); } // the call to Tracker.CurrentVisit.CampaignId will either work or throw try { Item campaign = Sitecore.Context.Database.GetItem(new ID(Tracker.CurrentVisit.CampaignId)); litCurrentCampaign.Text = campaign.Name; } catch { litCurrentCampaign.Text = GetDictionaryText("Current Campaign Empty"); } if (Tracker.CurrentVisit.HasGeoIpData) { litCity.Text = Tracker.CurrentVisit.City; litZip.Text = Tracker.CurrentVisit.PostalCode; } else { litCity.Text = GetDictionaryText("Pending Lookup"); litZip.Text = GetDictionaryText("Pending Lookup"); } PagesVisited.DataSource = Tracker.CurrentVisit.GetPages().Reverse(); PagesVisited.DataBind(); List <VisitorDataSet.PageEventsRow> Conversions = new List <VisitorDataSet.PageEventsRow>(); foreach (VisitorDataSet.PagesRow p in Tracker.CurrentVisit.GetPages()) { foreach (VisitorDataSet.PageEventsRow a in p.PageEvents) { if (a.PageEventDefinition.IsGoal) { Conversions.Add(a); } } } if (Conversions.Count > 0) { Conversions.Reverse(); GoalsAcheived.DataSource = Conversions; GoalsAcheived.DataBind(); GoalsEmpty.Visible = false; } } }