protected void rptDailyDetails_ItemDataBound(object sender, RepeaterItemEventArgs e) { if ((e.Item.ItemType == ListItemType.Item) || (e.Item.ItemType == ListItemType.AlternatingItem)) { DataRowView dr = (DataRowView)e.Item.DataItem; Sitecore.Data.ID itmID = (Sitecore.Data.ID.Parse(dr[1].ToString())); if (itmID != Sitecore.Data.ID.Null) { Sitecore.Data.Items.Item itm = webDB.GetItem(itmID); if (itm != null) { Label lblName = (Label)e.Item.FindControl("lblProductName"); if (lblName != null) { Item product = GetProductGroup(itm); if (product == null) { product = GetProductCategory(itm); } if (product != null) { lblName.Text = product.Fields["Product Group Name"].Value.ToString(); } } HtmlInputCheckBox cbItm = (HtmlInputCheckBox)e.Item.FindControl("cbItmID"); if (cbItm != null) { cbItm.Attributes.Add("onclick", String.Format("trackItemsToApprove('{0}', this);", itm.ID.ToString())); } } } } }
public ActionResult LatestNews() { PagedData <Data.Items.Item> listItems = new PagedData <Data.Items.Item>(); try { Sitecore.Data.Items.Item datasourceItem = RenderingContext.Current.Rendering.Item; Sitecore.Data.Fields.DatasourceField dsf = datasourceItem.Fields[Sitecore.Feature.Library.Templates.LatestArticleMBM.Fields.DataSource]; IEnumerable <Data.Items.Item> items = this.Repository.GetArticle(dsf.TargetItem); if (items != null && items.Count() > 0) { listItems.Data = items.Take(3); } listItems.DataSourceID = RenderingContext.Current.Rendering.Item.ID; } catch (Exception ex) { return(ErrorWebservice(new JavaScriptSerializer().Serialize(new ReturnErrorData { responseCode = "550", descErrorCode = ex.Message.ToString() }))); } return(View("~/Views/MBM/MBMLatestArticle.cshtml", listItems)); }
public static Item ValidIndexableItem(Sitecore.ContentSearch.IIndexable indexable, Sitecore.ContentSearch.ComputedFields.IComputedIndexField computedIndexField) { Assert.ArgumentNotNull(indexable, "indexable"); SC.ContentSearch.SitecoreIndexableItem scIndexable = indexable as SC.ContentSearch.SitecoreIndexableItem; if (scIndexable == null) { Log.Log.Warn( computedIndexField + " : unsupported IIndexable type : " + indexable.GetType()); return(null); } SC.Data.Items.Item item = (SC.Data.Items.Item)scIndexable; if (item == null) { Log.Log.Warn( computedIndexField + " : unsupported SitecoreIndexableItem type : " + scIndexable.GetType()); return(null); } if (item.Name == "__Standard Values") { Log.Log.Warn( computedIndexField + " : standard values' items are not indexed : " + scIndexable.GetType()); return(null); } return(item); }
/// <summary> /// Gets the icon of the item /// </summary> /// <param name="sitecoreItem">The item</param> /// <returns>The icon path</returns> public static string GetIcon(Sitecore.Data.Items.Item sitecoreItem) { if (sitecoreItem == null) { return(""); } string iconImageRaw = ThemeManager.GetIconImage(sitecoreItem, 32, 32, "", ""); if (!string.IsNullOrWhiteSpace(iconImageRaw) && iconImageRaw.Contains("src=")) { int i0 = iconImageRaw.IndexOf("src="); int i1 = iconImageRaw.IndexOf('"', i0 + 1); if (i1 < 0) { return(null); } int i2 = iconImageRaw.IndexOf('"', i1 + 1); if (i2 < 0) { return(null); } return(iconImageRaw.Substring(i1, i2 - i1).Trim(' ', '"', '\\')); } return(null); }
public ActionResult ImageStash() { int PageSize = RenderingContext.Current.Rendering.GetIntegerParameter("Max Item", 12); string _Year = RenderingContext.Current.Rendering.GetIntegerParameter("Year", DateTime.Now.Year).ToString(); //GetDataFrom Promotion Repository Sitecore.Data.Items.Item dataSourceItem = RenderingContext.Current.Rendering.Item; PagedData <Data.Items.Item> listItems = new PagedData <Data.Items.Item>(); try { IEnumerable <Data.Items.Item> items = this.Repository.GetGallery(dataSourceItem).Where(x => x.Fields[Sitecore.Feature.Library.Templates.BaseField.Fields._year] != null && x.Fields[Sitecore.Feature.Library.Templates.BaseField.Fields._year].Value == _Year); if (items != null && items.Count() > 0) { listItems.Data = items.Take(PageSize); listItems.NumberOfPages = Convert.ToInt32(Math.Ceiling((double)items.Count() / PageSize)); listItems.CurrentPage = 1; listItems.PageSize = PageSize; } listItems.DataSourceID = RenderingContext.Current.Rendering.Item.ID; } catch (Exception ex) { return(ErrorWebservice(new JavaScriptSerializer().Serialize(new ReturnErrorData { responseCode = "550", descErrorCode = ex.Message.ToString() }))); } return(View("~/Views/MBM/MBMImageStash.cshtml", listItems)); }
// GET: SampleItem/Sitecore/Details/5 public ActionResult Details(Guid id) { Sitecore.Data.Items.Item item = Context.Database.GetItem(new ID(id)); var sampleItem = StandardItemAdapter <Models.SampleItem> .CreateExtendedModelInstance(item, 1); return(Json(sampleItem, JsonRequestBehavior.AllowGet)); }
private void SetRight(Sitecore.Data.Items.Item item, Sitecore.Security.Accounts.Account account, Sitecore.Security.AccessControl.AccessRight right, Sitecore.Security.AccessControl.AccessPermission rightState, Sitecore.Security.AccessControl.PropagationType propagationType) { Sitecore.Security.AccessControl.AccessRuleCollection accessRules = item.Security.GetAccessRules(); if (propagationType == Sitecore.Security.AccessControl.PropagationType.Any) { accessRules.Helper.RemoveExactMatches(account, right); } else { accessRules.Helper.RemoveExactMatches(account, right, propagationType); } if (rightState != Sitecore.Security.AccessControl.AccessPermission.NotSet) { if (propagationType == Sitecore.Security.AccessControl.PropagationType.Any) { accessRules.Helper.AddAccessPermission(account, right, Sitecore.Security.AccessControl.PropagationType.Entity, rightState); accessRules.Helper.AddAccessPermission(account, right, Sitecore.Security.AccessControl.PropagationType.Descendants, rightState); } else { accessRules.Helper.AddAccessPermission(account, right, propagationType, rightState); } } item.Security.SetAccessRules(accessRules); }
protected override void Evaluate(CustomizeRenderingArgs args) { Sitecore.Diagnostics.Assert.ArgumentNotNull(args, "args"); Sitecore.Layouts.RenderingReference renderingReference = SelectVariation.GetRenderingReference(args.Rendering, Context.Language, args.PageContext.Database); if (string.IsNullOrEmpty(renderingReference.Settings.MultiVariateTest)) { return; } using (new Sitecore.SecurityModel.SecurityDisabler()) { Sitecore.Data.Items.Item item = args.PageContext.Database.GetItem(renderingReference.Settings.GetMultiVariateTestForLanguage(Context.Language)); if (item == null) { return; } MultivariateTestValueItem variation = this.GetVariation(item); if (variation == null) { return; } ComponentTestContext context = new ComponentTestContext(variation, renderingReference, new List <Sitecore.Layouts.RenderingReference> { renderingReference }); this.ApplyVariation(args, context); } args.IsCustomized = true; }
private Sitecore.Data.Items.Item retrieveItem(ListviewItem listItem) { string path = listItem.Header; Sitecore.Globalization.Language lang = Sitecore.Globalization.Language.Current; Sitecore.Data.Version version = Sitecore.Data.Version.Latest; Sitecore.Data.Items.Item item = null; if (listItem.ColumnValues.Contains("lang")) { Sitecore.Globalization.Language.TryParse(listItem.ColumnValues["lang"].ToString(), out lang); } if (listItem.ColumnValues.Contains("version")) { version = new Sitecore.Data.Version(listItem.ColumnValues["version"].ToString()); } item = Properties.Db.GetItem(path, lang, version); if (item == null) { if (Properties.Db.HasContentItem) { path = "/sitecore/content/" + path; item = Properties.Db.GetItem(path, lang, version); if (item != null) { return(item); } } throw new Exception("Item does not exist in such language"); } return(item); }
public ActionResult LatestImageGalleryPerYear() { Sitecore.Data.Items.Item datasourceItem = RenderingContext.Current.Rendering.Item; Sitecore.Data.Fields.DatasourceField dsf = datasourceItem.Fields[Sitecore.Feature.Library.Templates.LatestGalleryPerYearMBM.Fields.DataSource]; string _Year = datasourceItem.Fields[Sitecore.Feature.Library.Templates.BaseField.Fields._year] != null ? datasourceItem.Fields[Sitecore.Feature.Library.Templates.BaseField.Fields._year].ToString() : "2019"; PagedData <Data.Items.Item> listItems = new PagedData <Data.Items.Item>(); try { IEnumerable <Data.Items.Item> items = this.Repository.GetGallery(dsf.TargetItem).Where(x => x.Fields[Sitecore.Feature.Library.Templates.BaseField.Fields._year] != null && x.Fields[Sitecore.Feature.Library.Templates.BaseField.Fields._year].Value == _Year); if (items != null && items.Count() > 0) { listItems.Data = items.Take(4); } listItems.DataSourceID = RenderingContext.Current.Rendering.Item.ID; } catch (Exception ex) { return(ErrorWebservice(new JavaScriptSerializer().Serialize(new ReturnErrorData { responseCode = "550", descErrorCode = ex.Message.ToString() }))); } return(View("~/Views/MBM/MBMLatestImagePerYear.cshtml", listItems)); }
public bool SubmitData(RedeemPoint redeemPoint, int MaxSubmit) { int countEmail = CountEmail(redeemPoint); if (countEmail >= MaxSubmit) { return(false); } else { //methodsendEmail Sitecore.Data.Items.Item items = Sitecore.Context.Database.GetItem(redeemPoint.ItemId); EmailContent EmailToCustomer = GetEmailContent(Sitecore.Feature.Library.Helper.Variables._emailTemplatetoCustomer); //Email Template Redeem Point To Customer EmailToCustomer.EmailBody = EmailToCustomer.EmailBody.Replace("[CustomerName]", redeemPoint.Fullname); EmailToCustomer.EmailBody = EmailToCustomer.EmailBody.Replace("[ItemName]", redeemPoint.ItemName); EmailToCustomer.EmailBody = EmailToCustomer.EmailBody.Replace("[Points]", items.Fields[Sitecore.Feature.Library.Templates.TreatsPointItem.Fields.Price].Value); LibraryHelpers.SendEmail(redeemPoint.Email, EmailToCustomer.EmailFrom, EmailToCustomer.Subject, EmailToCustomer.EmailBody); //Get Email To Customer EmailContent EmailToCustomerCare = GetEmailContent(Sitecore.Feature.Library.Helper.Variables._emailTemplatetoCustomerCare); //Email Template Redeem Point To Customer Care EmailToCustomerCare.EmailBody = EmailToCustomerCare.EmailBody.Replace("[ItemName]", redeemPoint.ItemName); EmailToCustomerCare.EmailBody = EmailToCustomerCare.EmailBody.Replace("[Points]", items.Fields[Sitecore.Feature.Library.Templates.TreatsPointItem.Fields.Price].Value); EmailToCustomerCare.EmailBody = EmailToCustomerCare.EmailBody.Replace("[CustomerName]", redeemPoint.Fullname); EmailToCustomerCare.EmailBody = EmailToCustomerCare.EmailBody.Replace("[CCNumber]", redeemPoint.CreditCardNumber); EmailToCustomerCare.EmailBody = EmailToCustomerCare.EmailBody.Replace("[PhoneNumber]", redeemPoint.MobileNumber); EmailToCustomerCare.EmailBody = EmailToCustomerCare.EmailBody.Replace("[Email]", redeemPoint.Email); LibraryHelpers.SendEmail(GetUserEmailTo(Sitecore.Feature.Library.Helper.Variables._emailCustomerCareTreatsPoint), EmailToCustomerCare.EmailFrom, EmailToCustomerCare.Subject, EmailToCustomerCare.EmailBody); //Get Customer Care Email Add(redeemPoint); return(true); } }
public ActionResult SCNavigationBoxList() { List <SCNavigationBoxVM> navboxlist = new List <SCNavigationBoxVM>(); ChildList navBoxItems = Sitecore.Context.Database.GetItem("{2BDE8942-7089-46D4-A959-32A1C709B566}").Children; foreach (var navBox in navBoxItems) { Sitecore.Data.Items.Item navBoxItem = (Sitecore.Data.Items.Item)navBox; var navigationBoxVM = new SCNavigationBoxVM(navBoxItem); //var navboxitem = Sitecore.Context.Database.GetItem("{568325BB-0387-4FC2-90B5-6DE79965FDCF}"); //SCNavigationBoxVM navigationBoxVM = new SCNavigationBoxVM(navboxitem); List <SCNavigationVM> navList = new List <SCNavigationVM>(); MultilistField multilistField = Sitecore.Context.Database.GetItem(navBoxItem.ID.ToString()).Fields["NavigationList"]; if (multilistField != null) { Item[] navItems = multilistField.GetItems(); foreach (Item item in navItems) { navList.Add(new SCNavigationVM(item)); } } navigationBoxVM.NavigationList = navList; navboxlist.Add(navigationBoxVM); } return(PartialView(navboxlist)); }
public override string ResolveValue(Sitecore.Data.Items.Item item) { var templates = new StringBuilder(); GetAllTemplates(item.Template, templates); return(templates.ToString()); }
/// <summary> /// Create a Sublayout that supports the Rendering for the specified item /// </summary> /// <param name="item"></param> /// <returns></returns> public static Sublayout GetSublayoutForItem(Sitecore.Data.Items.Item item) { RenderingReference rendering = item.Visualization.GetRenderings(Sitecore.Context.Device, false).FirstOrDefault(); if (null != rendering) { var sublayout = new Sublayout(); sublayout.DataSource = item.ID.ToString(); sublayout.Path = rendering.RenderingItem.InnerItem["Path"]; sublayout.Cacheable = rendering.RenderingItem.Caching.Cacheable; // Copy cache settings if (rendering.RenderingItem.Caching.Cacheable) { sublayout.VaryByData = rendering.RenderingItem.Caching.VaryByData; sublayout.VaryByDevice = rendering.RenderingItem.Caching.VaryByDevice; sublayout.VaryByLogin = rendering.RenderingItem.Caching.VaryByLogin; sublayout.VaryByParm = rendering.RenderingItem.Caching.VaryByParm; sublayout.VaryByQueryString = rendering.RenderingItem.Caching.VaryByQueryString; sublayout.VaryByUser = rendering.RenderingItem.Caching.VaryByUser; } return(sublayout); } return(null); }
public ActionResult BlogStash() { var PageSize = RenderingContext.Current.Rendering.GetIntegerParameter("Max Item", 9); //GetDataFrom Promotion Repository Sitecore.Data.Items.Item dataSourceItem = RenderingContext.Current.Rendering.Item; PagedData <Data.Items.Item> listItems = new PagedData <Data.Items.Item>(); try { IEnumerable <Data.Items.Item> items = this.Repository.Get(dataSourceItem); if (items != null && items.Count() > 0) { listItems.Data = items.Take(PageSize); listItems.NumberOfPages = Convert.ToInt32(Math.Ceiling((double)items.Count() / PageSize)); listItems.CurrentPage = 1; listItems.PageSize = PageSize; } listItems.DataSourceID = RenderingContext.Current.Rendering.Item.ID; } catch (Exception ex) { return(ErrorWebservice(new JavaScriptSerializer().Serialize(new ReturnErrorData { responseCode = "550", descErrorCode = ex.Message.ToString() }))); } return(View("~/Views/MBM/BlogStash.cshtml", listItems)); }
/// <summary> /// Find the most appropriate teaser or summary text on the specified item. This may be a topic summary, /// or a page teaser, depending on the item's template. This method also handles the case where the method is /// wrapped in paragraph tags, and needs a "More" link inserted within those tags. /// </summary> /// <param name="item">The item from which to get the summary</param> /// <param name="urlMore">The "More" link (as in, "read more ... ") to tack at the end of the summary, /// before any closing paragraph tag</param> /// <returns>The summary tag</returns> public static String GetSummaryText(Sitecore.Data.Items.Item item) { String summary = String.Empty; if (null != item) { // The navigation page item field, if there is one, overrides the page header if (!String.IsNullOrEmpty(item["topicSummary"])) { summary = item["topicSummary"]; } else if (!String.IsNullOrEmpty(item["pageSummary"])) { summary = item["pageSummary"]; } else if (!String.IsNullOrEmpty(item["pageTeaser"])) { summary = item["pageTeaser"]; } else if (!String.IsNullOrEmpty(item["metaDescription"])) { summary = item["metaDescription"]; } } return(summary); }
private T Assign <T>(Sitecore.Data.Items.Item item) where T : new() { T t = new T(); Assign(item, t); return(t); }
/// <summary> /// Find the best name to display for the link's destination /// </summary> /// <param name="item"></param> /// <returns></returns> public static String GetLinkDestinationName(Sitecore.Data.Items.Item item) { if (null != item) { // TODO: Move these field names to a config file // The navigation page item field, if there is one, overrides the page header if (!String.IsNullOrEmpty(item["navigationPageTitle"])) { return(item["navigationPageTitle"]); } else if (!String.IsNullOrEmpty(item["pageHeader"])) { return(item["pageHeader"]); } else if (!String.IsNullOrEmpty(item["folderName"])) { return(item["folderName"]); } else if (!String.IsNullOrEmpty(item.DisplayName)) { return(item.DisplayName); } else { return(item.Name); } } return(String.Empty); }
/// <summary> /// Helper method to convert a pipe-delimited string of guids (for example, from a /// Sitecore multilist field) to a list of Sitecore items /// </summary> /// <param name="guidList">The pipe-delimited list of item IDs</param> /// <returns>A List containing the items matching the specified ID guids, or null if none were found</returns> public static List <Sitecore.Data.Items.Item> GetItemsFromStringOfGuids(String guidList) { if (!String.IsNullOrEmpty(guidList)) { var itemList = new List <Sitecore.Data.Items.Item>(); String[] guids = guidList.Split('|'); foreach (String g in guids) { Guid guid; if (Guid.TryParse(g, out guid)) { Sitecore.Data.Items.Item item = Sitecore.Context.Database.GetItem(new Sitecore.Data.ID(guid)); if (null != item) { itemList.Add(item); } } } // The method returns null instead of an empty list, in the expectation that it will be // hooked up to a Repeater if (itemList.Count > 0) { return(itemList); } } return(null); }
public ActionResult SendPoint([FromBody] PointsRequest request) { using (new DatabaseSwitcher(Factory.GetDatabase("master"))) { var team = Sitecore.Context.Database.GetItem(new ID(request.TeamId)); var judgeValuationTemplate = Sitecore.Context.Database.GetItem(new ID("{4CC5BB60-689D-46F1-83CB-348EA5DA3950}")); var folderTemplate = Sitecore.Context.Database.GetItem(new ID("{A87A00B1-E6DB-45AB-8B54-636FEC3B5523}")); Sitecore.Data.Items.Item judgesFolder = null; if (team.Children["Judges"] == null) { judgesFolder = team.Add("Judges", new TemplateItem(folderTemplate)); } else { judgesFolder = team.Children["Judges"]; } var judge = judgesFolder.Add(Sitecore.Context.User.LocalName, new TemplateItem(judgeValuationTemplate)); using (new EditContext(judge)) { judge["Point"] = request.Point; judge["Comments"] = request.Comment; } return(Json("Ok", JsonRequestBehavior.AllowGet)); } }
public void SetRight(string strDatabase, string strItem, string strAccount, string strRights, Sitecore.Security.AccessControl.AccessPermission rightState, Sitecore.Security.AccessControl.PropagationType propagationType, Credentials credentials) { Error.AssertString(strDatabase, "strDatabase", false); Error.AssertString(strItem, "strItem", false); Error.AssertString(strAccount, "strAccount", false); Error.AssertString(strRights, "strRights", false); Login(credentials); Sitecore.Data.Database db = Sitecore.Configuration.Factory.GetDatabase(strDatabase); Sitecore.Data.Items.Item item = db.GetItem(strItem); Sitecore.Security.Accounts.AccountType accountType = Sitecore.Security.Accounts.AccountType.User; if (Sitecore.Security.SecurityUtility.IsRole(strAccount)) { accountType = Sitecore.Security.Accounts.AccountType.Role; } Sitecore.Security.Accounts.Account account = Sitecore.Security.Accounts.Account.FromName(strAccount, accountType); // Always ensure that a minimum of 1 "|" character exists if (strRights.IndexOf("|") == -1) { strRights += '|'; } string[] strRightsList = strRights.Split('|'); for (int t = 0; t < strRightsList.Length; t++) { string strRight = strRightsList[t]; if ((strRight != null) && (strRight != "")) { Sitecore.Security.AccessControl.AccessRight right = Sitecore.Security.AccessControl.AccessRight.FromName(strRight); SetRight(item, account, right, rightState, propagationType); } } }
public ActionResult Edit(Guid id, FormCollection collection) { try { Sitecore.Data.Items.Item item = Context.Database.GetItem(new ID(id)); var sampleItem = StandardItemAdapter <Models.SampleItem> .CreateExtendedModelInstance(item, 1); var updateItem = new Models.SampleItem(); updateItem.Initialize(id); if (collection["Title"] != null) { updateItem.Title = collection["Title"]; } if (collection["Text"] != null) { updateItem.Text = collection["Text"]; } StandardItemAdapter <Models.SampleItem> .SaveModel(updateItem, item); return(RedirectToAction("Details", new { @id = id })); } catch { throw; } }
protected void AddNotification(string message, Sitecore.Data.Items.Item item, Sitecore.Pipelines.GetContentEditorWarnings.GetContentEditorWarningsArgs args, Item redirectitem) { Sitecore.Pipelines.GetContentEditorWarnings.GetContentEditorWarningsArgs.ContentEditorWarning note = args.Add(); note.Title = Translate.Text("Redirect Manager"); note.Text = String.Format(Translate.Text("The URL \"{0}\" is currently redirecting to this page."), redirectitem["Requested Url"]); note.AddOption(Translate.Text("Review the redirect definition"), string.Format("item:load(id={0}, language={1}, version={2})", redirectitem.ID, redirectitem.Language, redirectitem.Version)); note.AddOption(Translate.Text("Delete the redirect definition"), string.Format("redirectmanager:delete(id={0}, language={1}, version={2}, item={3})", redirectitem.ID, redirectitem.Language, redirectitem.Version, item.ID)); }
private void Page_Load(object sender, EventArgs e) { //ifuser is already logged in Please redirect to home page or returnurl page if (!this.Page.IsPostBack) { if (Request.IsAuthenticated) { Uri tempUri = new Uri("http://" + Request.Url.Host + Request.RawUrl.ToString()); string sQ = tempUri.Query; if (!string.IsNullOrEmpty(sQ)) { if (sQ.ToLower().Contains("returnurl=")) { sQ = sQ.Substring(sQ.ToLower().IndexOf("returnurl=") + 10); } } if (!string.IsNullOrEmpty(sQ)) { sQ = System.Web.HttpUtility.UrlDecode(sQ); if (!string.IsNullOrEmpty(sQ)) { // if (sQ.ToLower().Contains(System.Web.HttpContext.Current.Request.Url.Host.ToLower()) || sQ.ToLower().StartsWith("/")) Response.Redirect(sQ, true); } } Response.Redirect("/"); } } // Put user code to initialize the page here Sitecore.Data.Items.Item tempItem = Sitecore.Context.Item; tempItem = BGT.SitecoreLibrary.ContentUtil.GetLanguageVersion(tempItem); if (Sitecore.Context.Item.TemplateID.ToString() == "{260A7BB0-BDAA-4E81-A2DE-D687CDA5F33A}") { BGT.SitecoreLibrary.SectionTemplates.Login.LoginItem LoginPage = new BGT.SitecoreLibrary.SectionTemplates.Login.LoginItem(tempItem); ImagePath = LoginPage.BackgroundImage.MediaUrl; AltText = !string.IsNullOrEmpty(LoginPage.BackgroundImage.MediaItem.Alt) ? LoginPage.BackgroundImage.MediaItem.Alt : ""; } else if (Sitecore.Context.Item.TemplateID.ToString() == "{ABD7C33E-F098-49D7-A111-093086BBC945}") { BGT.SitecoreLibrary.SectionTemplates.Login.ForgotPasswordItem ForgotPasswordPage = new BGT.SitecoreLibrary.SectionTemplates.Login.ForgotPasswordItem(tempItem); ImagePath = ForgotPasswordPage.BackgroundImage.MediaUrl; AltText = !string.IsNullOrEmpty(ForgotPasswordPage.BackgroundImage.MediaItem.Alt) ? ForgotPasswordPage.BackgroundImage.MediaItem.Alt : ""; } else { tempItem = Sitecore.Context.Database.GetItem(new Sitecore.Data.ID("{F238BA3F-FF8A-430E-AAFD-09EAAC241238}")); tempItem = BGT.SitecoreLibrary.ContentUtil.GetLanguageVersion(tempItem); BGT.SitecoreLibrary.SectionTemplates.Login.LoginItem LoginPage = new BGT.SitecoreLibrary.SectionTemplates.Login.LoginItem(tempItem); ImagePath = LoginPage.BackgroundImage.MediaUrl; AltText = !string.IsNullOrEmpty(LoginPage.BackgroundImage.MediaItem.Alt) ? LoginPage.BackgroundImage.MediaItem.Alt : ""; } }
private void Page_Load(object sender, EventArgs e) { // Add the home link string homePath = "/sitecore/content/My First Site Exercise"; home = Sitecore.Context.Database.GetItem(homePath); MenuRepeater.DataSource = home.Children; MenuRepeater.DataBind(); }
/// <summary> /// Get the URL to an Item as a String, using the default UrlOptions /// </summary> /// <param name="item">The item</param> /// <returns></returns> public static String GetItemUrl(Sitecore.Data.Items.Item item) { if (null == item) { return(String.Empty); } return(Sitecore.Links.LinkManager.GetItemUrl(item, UrlOptions)); }
protected void rptCategories_ItemDataBound(object sender, RepeaterItemEventArgs e) { if ((e.Item.ItemType == ListItemType.Item) || (e.Item.ItemType == ListItemType.AlternatingItem)) { DataRowView dr = (DataRowView)e.Item.DataItem; Sitecore.Data.ID itmID = (Sitecore.Data.ID.Parse(dr["ProductCategoryItemID"].ToString())); if (itmID != Sitecore.Data.ID.Null) { Sitecore.Data.Items.Item itm = webDB.GetItem(itmID); if (itm != null) { Sitecore.Data.Fields.TextField catField = itm.Fields["Category"]; if ((catField != null) && (!String.IsNullOrWhiteSpace(catField.Value.ToString()))) { String category = catField.Value.ToString(); HtmlGenericControl lblName = (HtmlGenericControl)e.Item.FindControl("lblCategory"); if (lblName != null) { lblName.InnerHtml = itm.Fields["Category"].Value.ToString(); } HtmlAnchor anchr = (HtmlAnchor)e.Item.FindControl("CatAnch"); if (anchr != null) { anchr.Attributes.Add("href", String.Format("#{0}", category.ToLower().Replace(" ", ""))); } } } } DataView dv = dt.DefaultView; dv.RowFilter = String.Format("ProductCategoryItemID = '{0}'", itmID.ToString()); String[] ColumnsToFilter = { "ProductCategoryItemID", "ProductGroupItemID", "ItemID" }; DataTable distinctGroups = dv.ToTable(true, ColumnsToFilter); Repeater Groups = (Repeater)e.Item.FindControl("rptGroups"); if (Groups != null) { DataTable dtNew = distinctGroups; distinctGroups.Columns.Add("AttrWarnings"); foreach (DataRow drNew in dtNew.Rows) { ID ndcItemID = Sitecore.Data.ID.Parse(drNew["ItemID"]); if (ndcItemID != Sitecore.Data.ID.Null) { Item NDC = webDB.GetItem(ndcItemID); if (NDC != null) { drNew["AttrWarnings"] += NDC.Fields["_xAttrWarnings"].Value.ToString(); } } } Groups.DataSource = dtNew; Groups.DataBind(); } } }
/// <summary> /// Retrieves a URL for the specified media item /// </summary> /// <param name="itemId">The the media item to retrieve</param> /// <returns>A URL, or an empty string if it could not be found</returns> public static String GetMediaUrl(Sitecore.Data.Items.Item item) { if (null != item) { var media = new Sitecore.Data.Items.MediaItem(item); return(MediaManager.GetMediaUrl(media, MediaUrlOptions)); } return(String.Empty); }
private string GetLatestMvpYear(Sitecore.Data.Items.Item personItem) { var awards = GetAwardsTags(personItem); if (awards.Any()) { return(awards.First().Key.ToString()); } return(""); }
private string GetLatestMvpCategory(Sitecore.Data.Items.Item personItem) { var awards = GetAwardsTags(personItem); if (awards.Any()) { return(awards.First().Value); } return(""); }
public static DateTime GetDate(this Sitecore.Data.Items.Item item, string field) { Sitecore.Data.Fields.DateField dateField = item.Fields[field]; if (dateField != null) { return(dateField.DateTime); } return(DateTime.MinValue); }
public void SetCurrentUser() { if (Sitecore.Context.ClientData.GetValue("CurrentUser") != null) { String currentUserId = Sitecore.Context.ClientData.GetValue("CurrentUser").ToString(); CurrentUser = master.GetItem(currentUserId); } else { // possbile session timeout so redirect to the start Response.Redirect(Sitecore.Context.Site.StartPath); } }
// Methods public BucketItemAxes(Sitecore.Data.Items.Item item) { this._item = item; }