Beispiel #1
0
        /// <summary>
        /// Returns breadcrumbs specific to the block that should be added to navigation
        /// based on the current page reference.  This function is called during the page's
        /// oninit to load any initial breadcrumbs
        /// </summary>
        /// <param name="pageReference">The page reference.</param>
        /// <returns></returns>
        public override List <BreadCrumb> GetBreadCrumbs(PageReference pageReference)
        {
            var breadCrumbs = new List <BreadCrumb>();

            int?groupMemberId = PageParameter(pageReference, "GroupMemberId").AsIntegerOrNull();

            if (groupMemberId != null)
            {
                GroupMember groupMember = new GroupMemberService(new RockContext()).Get(groupMemberId.Value);
                if (groupMember != null)
                {
                    var parentPageReference = PageReference.GetParentPageReferences(this.RockPage, this.PageCache, pageReference).LastOrDefault();

                    if (parentPageReference != null)
                    {
                        var groupIdParam = parentPageReference.QueryString["GroupId"].AsIntegerOrNull();
                        if (!groupIdParam.HasValue || groupIdParam.Value != groupMember.GroupId)
                        {
                            // if the GroupMember's Group isn't included in the breadcrumbs, make sure to add the Group to the breadcrumbs so we know which group the group member is in
                            breadCrumbs.Add(new BreadCrumb(groupMember.Group.Name, true));
                        }
                    }

                    breadCrumbs.Add(new BreadCrumb(groupMember.Person.FullName, pageReference));
                }
                else
                {
                    breadCrumbs.Add(new BreadCrumb("New Group Member", pageReference));
                }
            }
            else
            {
                // don't show a breadcrumb if we don't have a pageparam to work with
            }

            return(breadCrumbs);
        }