Ejemplo n.º 1
0
        protected override void Page_Load(object sender, EventArgs e)
        {
            base.Page_Load(sender, e);

            SubmitButton.Text = FormTextUtility.Provider.GetTextByKey("/EditAccount/ChangePassword");

            BackLink.NavigateUrl = SitecoreUtility.GetItemURL(PreferredDataSource.Parent);
        }
Ejemplo n.º 2
0
        protected override void Page_Load(object sender, EventArgs e)
        {
            base.Page_Load(sender, e);

            SubmitButton.Text = FormTextUtility.Provider.GetTextByKey("/EditAccount/ChangeEmail");

            //set the current email to the form
            OldEmail.Text = Sitecore.Context.User.Profile.Email;

            BackLink.NavigateUrl = SitecoreUtility.GetItemURL(PreferredDataSource.Parent);
        }
Ejemplo n.º 3
0
        protected string GetURL(string template)
        {
            Item p = PreferredDataSource.ChildByTemplateID(template);

            return((p != null) ? SitecoreUtility.GetItemURL(p) : string.Empty);
        }
Ejemplo n.º 4
0
        public ActionResult RenderTagsOrCategoriesSidebarFilter()
        {
            TagsOrCategoriesSidebarFilter viewModel = null;

            try
            {
                string blogArchivePageItemID = SitecoreUtility.GetRenderingParameters(References.Templates.TagsOrCategoriesSidebarFilter.ID, References.Templates.TagsOrCategoriesSidebarFilter.Fields.BlogArchivePage);

                if (!string.IsNullOrEmpty(blogArchivePageItemID))
                {
                    Item blogArchivePageItem = SitecoreUtility.GetItem(new ID(blogArchivePageItemID));

                    if (blogArchivePageItem != null)
                    {
                        viewModel = new TagsOrCategoriesSidebarFilter();
                        viewModel.SectionTitle       = SitecoreUtility.GetRenderingParameters(References.Templates.TagsOrCategoriesSidebarFilter.ID, References.Templates.TagsOrCategoriesSidebarFilter.Fields.SectionTitle);
                        viewModel.DisplayItemsAsTags = SitecoreUtility.GetRenderingParameters(References.Templates.TagsOrCategoriesSidebarFilter.ID, References.Templates.TagsOrCategoriesSidebarFilter.Fields.DisplayItemsAsTags) == "1";
                        viewModel.BlogArchivePageURL = SitecoreUtility.GetItemURL(blogArchivePageItem);

                        if (!viewModel.DisplayItemsAsTags)
                        {
                            List <BlogCategory> categoriesUsedByBlogs = new List <BlogCategory>();
                            Item blogCategoriesFolderItem             = SitecoreUtility.GetItem(References.Content.BlogCategoriesFolder);

                            if (blogCategoriesFolderItem != null && blogCategoriesFolderItem.HasChildren)
                            {
                                List <Item> activeCategories = SitecoreUtility.GetItemsByTemplate(blogCategoriesFolderItem, References.Templates.BlogCategory.ID)
                                                               .Where(x => x.Fields[References.Templates.BlogCategory.Fields.IsActive].Value == "1").ToList();

                                if (activeCategories != null && activeCategories.Count > 0)
                                {
                                    foreach (Item category in activeCategories)
                                    {
                                        if (SitecoreUtility.HasReferrers(category, References.Templates.BlogPage.ID, References.Templates.Blog.Fields.IsActive))
                                        {
                                            BlogCategory blogCategory = new BlogCategory(category);
                                            categoriesUsedByBlogs.Add(blogCategory);
                                        }
                                    }

                                    viewModel.BlogCategories = categoriesUsedByBlogs;
                                }
                            }
                        }
                        else
                        {
                            List <BlogTag> tagsUsedByBlogs    = new List <BlogTag>();
                            Item           blogTagsFolderItem = SitecoreUtility.GetItem(References.Content.BlogTagsFolder);

                            if (blogTagsFolderItem != null && blogTagsFolderItem.HasChildren)
                            {
                                List <Item> activeTags = SitecoreUtility.GetItemsByTemplate(blogTagsFolderItem, References.Templates.BlogTag.ID)
                                                         .Where(x => x.Fields[References.Templates.BlogTag.Fields.IsActive].Value == "1").ToList();

                                if (activeTags != null && activeTags.Count > 0)
                                {
                                    foreach (Item tag in activeTags)
                                    {
                                        if (SitecoreUtility.HasReferrers(tag, References.Templates.BlogPage.ID, References.Templates.Blog.Fields.IsActive))
                                        {
                                            BlogTag blogTag = new BlogTag(tag);
                                            tagsUsedByBlogs.Add(blogTag);
                                        }
                                    }

                                    viewModel.BlogTags = tagsUsedByBlogs;
                                }
                            }
                        }
                    }
                }
            }
            catch (System.Exception ex)
            {
                LogManager.SaveLog(System.Reflection.MethodBase.GetCurrentMethod().ReflectedType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name, ex, LogManager.LogTypes.Error, string.Empty);
            }

            return(View(GlobalConstants.SUBLAYOUTS_PATH + "PageContent/TagsOrCategoriesSidebarFilter.cshtml", viewModel));
        }
Ejemplo n.º 5
0
        /// <summary>
        /// gets courses by page
        /// </summary>
        /// <param name="parentItem">If its first page, parent item should be passed. All its child pages will be verified.</param>
        /// <param name="pageNumber">1 is for first page, 2 is for next page & 0 is for previous page</param>
        /// <param name="referenceCourseItemID">the course item id of the first or last course teaser on page</param>
        /// <returns></returns>
        private Blog GetBlogByPage(string pageNumber, string currentBlogItemID)
        {
            Blog        blog               = null;
            Item        currentBlogItem    = null;
            Item        parentItem         = null;
            List <Item> activeBlogItems    = null;
            int         indexOfCurrentItem = -1;

            if (!string.IsNullOrEmpty(pageNumber))
            {
                if (pageNumber == "1" && Sitecore.Context.Item.TemplateID == References.Templates.BlogPage.ID)
                {
                    blog            = new Blog(Sitecore.Context.Item);
                    parentItem      = Sitecore.Context.Item.Parent;
                    activeBlogItems = parentItem != null?parentItem.Children
                                      .Where(x => x.TemplateID == References.Templates.BlogPage.ID && x.Fields[References.Templates.Blog.Fields.IsActive].Value == "1")
                                      .OrderBy(b => Sitecore.DateUtil.ToServerTime(Sitecore.DateUtil.IsoDateToDateTime(b.Fields[References.Templates.Blog.Fields.PostedDate].Value))).ToList() : null;

                    if (activeBlogItems != null && activeBlogItems.Count > 1)
                    {
                        indexOfCurrentItem = activeBlogItems.FindIndex(x => x.ID == Sitecore.Context.Item.ID);
                    }
                }
                else if (!string.IsNullOrEmpty(currentBlogItemID) && (pageNumber == "0" || pageNumber == "2"))
                {
                    currentBlogItem = SitecoreUtility.GetItem(new ID(currentBlogItemID));

                    parentItem      = currentBlogItem != null ? currentBlogItem.Parent : null;
                    activeBlogItems = parentItem != null?parentItem.Children
                                      .Where(x => x.TemplateID == References.Templates.BlogPage.ID && x.Fields[References.Templates.Blog.Fields.IsActive].Value == "1")
                                      .OrderBy(b => Sitecore.DateUtil.ToServerTime(Sitecore.DateUtil.IsoDateToDateTime(b.Fields[References.Templates.Blog.Fields.PostedDate].Value))).ToList() : null;

                    if (activeBlogItems != null && activeBlogItems.Count > 1)
                    {
                        indexOfCurrentItem = activeBlogItems.FindIndex(x => x.ID == currentBlogItem.ID);
                        Item siblingBlogItem = null;

                        if (pageNumber == "0" && indexOfCurrentItem > 0)
                        {
                            //get previous blog item
                            siblingBlogItem = activeBlogItems[indexOfCurrentItem - 1];
                        }
                        else if (pageNumber == "2" && indexOfCurrentItem < (activeBlogItems.Count - 1))
                        {
                            //get next blog item
                            siblingBlogItem = activeBlogItems[indexOfCurrentItem + 1];
                        }

                        if (siblingBlogItem != null)
                        {
                            blog = new Blog(siblingBlogItem);
                            indexOfCurrentItem = activeBlogItems.FindIndex(x => x.ID == siblingBlogItem.ID);
                        }
                    }
                }

                if (blog != null && blog.IsActive)
                {
                    blog.RelatedPosts    = GetRelatedPosts(blog.InnerItem, References.Templates.Blog.Fields.RelatedPosts);
                    blog.PreviousBlogURL = indexOfCurrentItem > 0 ? SitecoreUtility.GetItemURL(activeBlogItems[indexOfCurrentItem - 1]) : "";
                    blog.NextBlogURL     = indexOfCurrentItem < (activeBlogItems.Count - 1) ? SitecoreUtility.GetItemURL(activeBlogItems[indexOfCurrentItem + 1]) : "";
                }
                else
                {
                    blog = null;
                }
            }

            return(blog);
        }