Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at

  • pubudu 30 posts 133 karma points
    Aug 05, 2019 @ 05:52

    I need to add 2 sections on my web page. Like below

    Team Member: enter image description here Brands: enter image description here

    And I used to the new template to add those new items. enter image description here

    But finally all the new items I added, show in both places. enter image description here

    My Controller

    public ActionResult RenderAboutTeamMember()
        {List<MemberPreview> model = new List<MemberPreview>();
            IPublishedContent memberPage = CurrentPage.AncestorOrSelf(1).DescendantsOrSelf().Where(x => x.DocumentTypeAlias == "about").FirstOrDefault();
            foreach (IPublishedContent page in memberPage.Children)
                int imageId2 = page.GetPropertyValue<int>("MemberImage");
                var mediaItem2 = Umbraco.Media(imageId2);
                model.Add(new MemberPreview(page.Name, 
            return PartialView("~/Views/Partials/Home/About/About_TeamMembers.cshtml", model);
        public ActionResult RenderAboutBrands()
            List<Brands> model = new List<Brands>();
            IPublishedContent homePage = 
            CurrentPage.AncestorOrSelf(1).DescendantsOrSelf().Where(x => 
             x.DocumentTypeAlias == "about").FirstOrDefault();
            ArchetypeModel Brands = 
            foreach (ArchetypeFieldsetModel fieldset in Brands)
              var mediaItem = fieldset.GetValue<IPublishedContent>("imageLogo");
              string Bimage = mediaItem.Url;
              model.Add(new Brands(fieldset.GetValue<string>("brandName"), Bimage));
            return PartialView("~/Views/Partials/Home/About/About_Brands.cshtml", model);

    My Brand Model:

     public class BrandPreview
        public string BrandName { get; set; }
        public string BrandImageUrl { get; set; }
        public string BrandLink { get; set; }
        public string BrandLinkUrl { get; set; }
        public BrandPreview(string brandname, string brandimageurl, string brandlinkurl,string brandlink)
            BrandName = brandname;
            BrandImageUrl = brandimageurl;
            BrandLink = brandlink;
            BrandLinkUrl = brandlinkurl;

    My Member Model:

     public class MemberPreview
        public string MemberName { get; set; }
        public string MemberPost { get; set; }
        public string MemberIntroduction { get; set; }
        public string MemberImageUrl { get; set; }
        public string MemberLinkUrl { get; set; }
        public string MemberLinkedin { get; set; }
        public string MemberTwitter { get; set; }
        public string MemberFacebook { get; set; }
        public string MemberInstagram { get; set; }
        public MemberPreview(string membername,string memberpost, string memberintro, string memberlinkedinLink, string membertwitterLink, string memberfaceBookLink, string memberinstragramLink, string memberimageurl, string memberlinkurl)
            MemberName = membername;
            MemberPost = memberpost;
            MemberIntroduction = memberintro;
            MemberImageUrl = memberimageurl;
            MemberLinkUrl = memberlinkurl;
            MemberLinkedin = memberlinkedinLink;
            MemberTwitter = membertwitterLink;
            MemberFacebook = memberfaceBookLink;
            MemberInstagram = memberinstragramLink;

    I think problem is controller page hear identify all the children page in current page. How can fix it???

  • Marc Goodson 2148 posts 14353 karma points MVP 8x c-trib
    Aug 06, 2019 @ 15:16
    Marc Goodson

    Hi pubudu

    I'm wondering if in your foreach loop you can filter out by 'document type alias'?


    foreach (IPublishedContent page in memberPage.Children.Where(f=>f.DocumentTypeAlias == "memberPost")) {

    this should mean that none of your brandPost items will be included in your first grouping.



  • pubudu 30 posts 133 karma points
    Aug 08, 2019 @ 04:36

    Thanks Marc. It's work. I'm a beginner to Umbraco and I had much time to waste find this. Thanks again. regards

Please Sign in or register to post replies

Write your reply to: