public override void Initialize(Rendering rendering) { try { base.Initialize(rendering); Rendering = rendering; dsIsSet = !String.IsNullOrEmpty(rendering.DataSource) && Sitecore.Context.Database.GetItem(rendering.DataSource) == null; Sitecore.Marketing.Wildcards.WildcardTokenizedString wts = Sitecore.Marketing.Wildcards.WildcardManager.Provider.GetWildcardUrl(PageItem, Sitecore.Context.Site); System.Collections.Specialized.NameValueCollection tokens = wts.FindTokenValues(HttpContext.Current.Request.Path.ToLower().Replace(' ', '-')); strPID = tokens["%Person_ID%"]; if (strPID != null) { validId = Int32.TryParse(strPID, out personID); } if (validId && !Sitecore.Context.PageMode.IsExperienceEditorEditing) { try { person = new HealthIS.Apps.FacultyDirectory.Profile(personID, HealthIS.Apps.FacultyDirectory.Profile.ProfileType.Research, HealthIS.Apps.FacultyDirectory.Profile.ProfileParts.All); //Page.Title = person.firstName + " " + person.lastName + " - USF Health - Tampa, FL"; } catch (Exception ex) { //errorText.Text += "<br/>"+id; //errorText.Text = ex.ToString(); } } } catch (Exception ex) { Errors += ex.Message + "<br/>" + ex.InnerException + "<br/>" + ex.StackTrace; } }
public static string pageTitle() { string name = ""; Sitecore.Marketing.Wildcards.WildcardTokenizedString wts = Sitecore.Marketing.Wildcards.WildcardManager.Provider.GetWildcardUrl(PageContext.Current.Item, Sitecore.Context.Site); System.Collections.Specialized.NameValueCollection tokens = wts.FindTokenValues(HttpContext.Current.Request.Path.ToLower().Replace(' ', '-')); string strPID = tokens["%Person_ID%"]; int pid = -1; bool validId = false; if (strPID != null) { validId = Int32.TryParse(strPID, out pid); } if (validId && !Sitecore.Context.PageMode.IsExperienceEditorEditing) { try { HealthIS.Apps.FacultyDirectory.Profile p = new HealthIS.Apps.FacultyDirectory.Profile(pid, HealthIS.Apps.FacultyDirectory.Profile.ProfileType.Research, HealthIS.Apps.FacultyDirectory.Profile.ProfileParts.All); name = p.firstName + " " + p.lastName; if (!String.IsNullOrEmpty(p.title)) { name += ", " + p.title; } var pgField = PageContext.Current.Item.Fields["Page Title"]; if (pgField != null) { name += " | " + pgField.Value; } } catch { } } return(name); }
public ActionResult FacultyDirectoryCorporateProfile() { FacultyDirectoryCorporateProfile facultyProfile = new FacultyDirectoryCorporateProfile(); facultyProfile.rendering = Sitecore.Mvc.Presentation.RenderingContext.CurrentOrNull.Rendering; facultyProfile.pageItem = PageContext.Current.Item; facultyProfile.showError = ""; try { // Set datasource if it is empty if (String.IsNullOrEmpty(facultyProfile.rendering.DataSource)) { using (new Sitecore.SecurityModel.SecurityDisabler()) { //Get current rendering item Sitecore.Layouts.RenderingReference[] renderings = facultyProfile.pageItem.Visualization.GetRenderings(Sitecore.Context.Device, true).Where(r => r.RenderingID == facultyProfile.rendering.RenderingItem.ID).ToArray(); // Get the layout definitions and the device Sitecore.Data.Fields.LayoutField layoutField = new Sitecore.Data.Fields.LayoutField(facultyProfile.pageItem.Fields[Sitecore.FieldIDs.FinalLayoutField]); Sitecore.Layouts.LayoutDefinition layoutDefinition = Sitecore.Layouts.LayoutDefinition.Parse(layoutField.Value); Sitecore.Layouts.DeviceDefinition deviceDefinition = layoutDefinition.GetDevice(Sitecore.Context.Device.ID.ToString()); foreach (Sitecore.Layouts.RenderingReference rendering in renderings) { // Update the renderings datasource value as current item path deviceDefinition.GetRendering(rendering.RenderingID.ToString()).Datasource = facultyProfile.pageItem.ID.ToString(); // Save the layout changes facultyProfile.pageItem.Editing.BeginEdit(); layoutField.Value = layoutDefinition.ToXml(); facultyProfile.pageItem.Editing.EndEdit(); } } } Sitecore.Marketing.Wildcards.WildcardTokenizedString wts = Sitecore.Marketing.Wildcards.WildcardManager.Provider.GetWildcardUrl(facultyProfile.PageItem, Sitecore.Context.Site); System.Collections.Specialized.NameValueCollection tokens = wts.FindTokenValues(Request.Path.ToLower().Replace(' ', '-')); facultyProfile.strPID = tokens["%Person_ID%"]; if (facultyProfile.strPID != null) { facultyProfile.validId = Int32.TryParse(facultyProfile.strPID, out facultyProfile.personID); } if (facultyProfile.validId && !Sitecore.Context.PageMode.IsExperienceEditorEditing) { facultyProfile.person = new HealthIS.Apps.FacultyDirectory.Profile(facultyProfile.personID, HealthIS.Apps.FacultyDirectory.Profile.ProfileType.Research, HealthIS.Apps.FacultyDirectory.Profile.ProfileParts.All); } } catch (Exception ex) { facultyProfile.showError = "Sorry for the inconvenience.<br />We’re performing some maintenance at the moment."; Sitecore.Diagnostics.Log.SingleWarn("Error from faculty profile page at " + Request.Url.Host + " - " + ex.Message, this); facultyProfile.person = null; } return(PartialView(facultyProfile)); }
public static Tuple <string, string> GetHeaderData() { string getPageTitle = ""; string getMetaDesc = ""; int pid = -1; bool validId = false; Sitecore.Marketing.Wildcards.WildcardTokenizedString wts = Sitecore.Marketing.Wildcards.WildcardManager.Provider.GetWildcardUrl(PageContext.Current.Item, Sitecore.Context.Site); System.Collections.Specialized.NameValueCollection tokens = wts.FindTokenValues(HttpContext.Current.Request.Path.ToLower().Replace(' ', '-')); string strPID = tokens["%Person_ID%"]; if (strPID != null) { validId = Int32.TryParse(strPID, out pid); } if (validId && !Sitecore.Context.PageMode.IsExperienceEditorEditing) { try { HealthIS.Apps.FacultyDirectory.Profile p = new HealthIS.Apps.FacultyDirectory.Profile(pid, HealthIS.Apps.FacultyDirectory.Profile.ProfileType.Research, HealthIS.Apps.FacultyDirectory.Profile.ProfileParts.All); getPageTitle = p.firstName + " " + p.lastName; getMetaDesc = p.firstName + " " + p.lastName; if (!String.IsNullOrEmpty(p.title)) { getPageTitle += ", " + p.title; getMetaDesc += ", " + p.title; } var pgField = PageContext.Current.Item.Fields["Page Title"]; if (!String.IsNullOrEmpty(pgField.ToString().Trim())) { getPageTitle += " | " + pgField.Value; getMetaDesc += " - " + pgField.Value; } // Meta Description if (!string.IsNullOrEmpty(p.degrees)) { getMetaDesc += StripTagsRegex(" - " + p.degrees.Replace("</li><li>", ", ")); } } catch { getPageTitle = ""; getMetaDesc = ""; } } return(Tuple.Create(getPageTitle, getMetaDesc)); }
public void GetNursingPersonData() { Sitecore.Marketing.Wildcards.WildcardTokenizedString wts = Sitecore.Marketing.Wildcards.WildcardManager.Provider.GetWildcardUrl(PageContext.Current.Item, Sitecore.Context.Site); System.Collections.Specialized.NameValueCollection tokens = wts.FindTokenValues(HttpContext.Current.Request.Path.ToLower().Replace(' ', '-')); string strPID = tokens["%Person_ID%"]; if (strPID != null) { validId = Int32.TryParse(strPID, out personID); } if (validId && !Sitecore.Context.PageMode.IsExperienceEditorEditing) { try { person = new HealthIS.Apps.FacultyDirectory.Profile(personID, HealthIS.Apps.FacultyDirectory.Profile.ProfileType.Research, HealthIS.Apps.FacultyDirectory.Profile.ProfileParts.All); } catch { } } }