protected void Page_Load(object sender, EventArgs e) { section = Sitecore.Web.WebUtil.GetQueryString("section"); Item[] firstList = currentItem.InnerItem.Axes.SelectItems(String.Format(@"ancestor-or-self::*[@@tid=""{0}"" or @@tid=""{1}""]/child::*", ClassicClubItem.TemplateId, LifeCentreItem.TemplateId)); if (firstList != null) { List<Item> firstLevelList = firstList.ToList(); List<Item> contextAncestorsOrSelf = currentItem.InnerItem.Axes.SelectItems("./ancestor-or-self::*").ToList(); List<PageSummaryItem> firstLevel = firstLevelList.ConvertAll(x => new PageSummaryItem(x)); firstLevel.RemoveAll(x => x.Hidefrommenu.Checked); firstLevel.Last().IsLast = true; //need to figure out the 'active' first level item (the one to highlight) //This can then also be used to build to second level foreach (PageSummaryItem item in firstLevel) { if (SitecoreHelper.ListContainsItem(contextAncestorsOrSelf, item.InnerItem)) { item.IsCurrent = true; currentfirstLevelItem = item; break; } } //Bind the first level items TopElements.DataSource = firstLevel; TopElements.DataBind(); } if (currentfirstLevelItem != null && (currentfirstLevelItem.InnerItem.TemplateID.ToString() != ItemPaths.BlogTemplateId) && (currentfirstLevelItem.InnerItem.TemplateID.ToString() != TimetableDownloadItem.TemplateId) && (currentfirstLevelItem.InnerItem.TemplateID.ToString() != FeedbackItem.TemplateId) ) { //Do not build the second level for blog section. if (currentfirstLevelItem.InnerItem.HasChildren) { bool notBound = true; if (currentfirstLevelItem.InnerItem.TemplateID.ToString() == HealthAndBeautyLandingItem.TemplateId) { //Get treatment listing details ClubHealthAndBeautyListingItem listing = new ClubHealthAndBeautyListingItem(Sitecore.Context.Item); //Get the facility modules that are to be shown on listing page List<TreatmentModuleItem> treatmentModules = listing.Sharedtreatments.ListItems.ToList().ConvertAll(X => new TreatmentModuleItem(X)); HealthAndBeautyLandingItem currentBrand = null; HealthAndBeautyListingItem currentListing = null; List<HealthAndBeautyListingItem> sharedListings = new List<HealthAndBeautyListingItem>(); List<HealthAndBeautyListingItem> clubListings = new List<HealthAndBeautyListingItem>(); List<HealthAndBeautyListingItem> clubListingsAvailable = new List<HealthAndBeautyListingItem>(); foreach (TreatmentModuleItem module in treatmentModules) { //if first item load the shared content if (currentBrand == null) { //find which brand the treatment belongs to Item brand = module.InnerItem.Axes.SelectSingleItem(String.Format(@"ancestor-or-self::*[@@tid=""{0}""]", HealthAndBeautyLandingItem.TemplateId)); if (brand != null) { currentBrand = new HealthAndBeautyLandingItem(brand); sharedListings = currentBrand.InnerItem.Axes.SelectItems(String.Format("descendant-or-self::*[@@tid = '{0}']", HealthAndBeautyListingItem.TemplateId)).ToList().ConvertAll(x => new HealthAndBeautyListingItem(x)); } } //check current listing currentListing = new HealthAndBeautyListingItem(module.InnerItem.Axes.SelectSingleItem(String.Format(@"ancestor-or-self::*[@@tid=""{0}""]", HealthAndBeautyListingItem.TemplateId))); if(currentListing != null) { //Add listing to the listings available collection bool blnExist = false; //Check if it exists already foreach (HealthAndBeautyListingItem existingClubListings in clubListingsAvailable) { if(existingClubListings.ID.ToString() == currentListing.ID.ToString()) { blnExist = true; break; } } if(blnExist == false) { //Check that it exists as a listing under the shared brand foreach (HealthAndBeautyListingItem sharedList in sharedListings) { if (sharedList.ID.ToString() == currentListing.ID.ToString()) { clubListingsAvailable.Add(currentListing); } } } } } if (clubListingsAvailable.Count > 1) { HealthAndBeautySecondaryNav(clubListingsAvailable, new PageSummaryItem(currentfirstLevelItem.InnerItem.Children[0]).Url); } notBound = false; } if (notBound) { DataBindSecondaryNav(currentfirstLevelItem.InnerItem, ""); } } } }
protected void Page_Load(object sender, EventArgs e) { //Check if listing is already initialised (i.e. loaded as the default listing page for the landing page) if (listing != null) { //Add datepicker jquery plugin script this.Page.FindControl("ScriptPh").Controls.Add(new LiteralControl(@"<script src=""/virginactive/scripts/jquery-ui-1.8.15.custom.min.js""></script>")); //Register script this.Page.FindControl("ScriptPh").Controls.Add(new LiteralControl(@"<script> $(function(){ $.va_init.functions.addDatepicker(); $.va_init.functions.addTreatmentToDropDown(); }); </script>")); //Get club club = SitecoreHelper.GetCurrentClub(listing.InnerItem); //get the details of the first manager listed for the club (i.e. the manager) List<ManagerItem> staffMembers = null; Item[] mgrItems = club.InnerItem.Axes.SelectItems(String.Format("descendant-or-self::*[@@tid = '{0}']", ManagerItem.TemplateId)); if (mgrItems != null) { staffMembers = mgrItems.ToList().ConvertAll(x => new ManagerItem(x)); clubManager = staffMembers.First(); } //Get the facility modules that are to be shown on listing page treatmentModules = listing.Sharedtreatments.ListItems.ToList().ConvertAll(X => new TreatmentModuleItem(X)); foreach (TreatmentModuleItem module in treatmentModules) { //find which brand the treatment belows to sharedLanding = new HealthAndBeautyLandingItem(module.InnerItem.Axes.SelectSingleItem(String.Format(@"ancestor-or-self::*[@@tid=""{0}""]", HealthAndBeautyLandingItem.TemplateId))); sharedListing = new HealthAndBeautyListingItem(module.InnerItem.Axes.SelectSingleItem(String.Format(@"ancestor-or-self::*[@@tid=""{0}""]", HealthAndBeautyListingItem.TemplateId))); break; } if (sharedLanding != null) { string section = Sitecore.Web.WebUtil.GetQueryString("section"); if (!String.IsNullOrEmpty(section)) { //get the correct section listing item from the querystring sharedListing = sharedLanding.InnerItem.Axes.GetDescendant(section); } if (sharedListing != null) { if (listing.Pricelistavailable.Checked == true && listing.Pricelist != null) { downloadPriceListUrl = listing.Pricelist.MediaUrl; downloadPriceList = @"<li><a href=""" + downloadPriceListUrl + @""">" + Translate.Text("Download a price list") + "</a></li>"; } else { PriceList.Visible = false; } //Get list of shared treaments if (sharedListing.InnerItem.HasChildren) { List<TreatmentModuleItem> sharedTreatmentList = sharedListing.InnerItem.Children.ToList().ConvertAll(X => new TreatmentModuleItem(X)); foreach (TreatmentModuleItem sharedTreatmentModule in sharedTreatmentList) { //Check if this treatment has been included for this club foreach(TreatmentModuleItem module in treatmentModules) { if (module.ID.ToString() == sharedTreatmentModule.ID.ToString()) { //Show this treatment treatmentListToShow.Add(module); } } } if (treatmentListToShow.Count > 0) { treatmentListToShow.First().IsFirst = true; TreatmentList.DataSource = treatmentListToShow; TreatmentList.DataBind(); } } } } string val = Translate.Text("Please enter {0}"); rfvName.ErrorMessage = String.Format("<div class='error-msg'><p>{0}</p></div>", String.Format(val, Translate.Text("a name"))); revName.ErrorMessage = String.Format("<div class='error-msg'><p>{0}</p></div>", String.Format(val, Translate.Text("a valid name"))); rfvEmail.ErrorMessage = String.Format("<div class='error-msg'><p>{0}</p></div>", String.Format(val, Translate.Text("an email address"))); revEmail.ErrorMessage = String.Format("<div class='error-msg'><p>{0}</p></div>", String.Format(val, Translate.Text("a valid email address"))); rfvPhone.ErrorMessage = String.Format("<div class='error-msg'><p>{0}</p></div>", String.Format(val, Translate.Text("a phone number"))); revPhone.ErrorMessage = String.Format("<div class='error-msg'><p>{0}</p></div>", String.Format(val, Translate.Text("a valid phone number"))); //rfvComments.ErrorMessage = String.Format("<p>{0}</p>", String.Format(val, Translate.Text("your comments"))); revEmail.ValidationExpression = Settings.EmailAddressRegularExpression; revPhone.ValidationExpression = Settings.PhoneNumberRegularExpression; revName.ValidationExpression = Settings.NameRegularExpression; if (!Page.IsPostBack) { BindDropDownLists(); } } this.Page.FindControl("ScriptPh").Controls.Add(new LiteralControl(@"<script> $(function(){ $.va_init.functions.setupForms(); }); </script>")); }