Copied to clipboard

Flag this post as spam?

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


  • Kristoffer Lindén 12 posts 122 karma points
    Jul 08, 2019 @ 11:37
    Kristoffer Lindén
    0

    New section not showing

    Hi!

    I'm trying to add a new section by code but I can't get it to show:

    public void Compose(Composition composition)
    {                         
        composition.Sections().Append<MySection>();                    
    }
    

    The section:

    public class MySection : ISection
    {
        public string Alias => "mySection";
    
        public string Name => "My Section";
    }
    

    The section gets added to the collection but nothing is rendered?

    Any ideas why?

    Thanks!

    /Kristoffer

  • Kevin Jump 2341 posts 14868 karma points MVP 8x c-trib
    Jul 08, 2019 @ 12:27
    Kevin Jump
    100

    Hi Kristoffer,

    By default, a new section won't display until you have added it to the list of visible sections for a user group.

    If you go to the users' section, click on groups in the top right-hand corner

    enter image description here

    select administrators

    enter image description here

    and then add the section to the list,

    enter image description here

    save and then refresh the browser, the section should appear.

    Programmatically.

    you can add a section to a user group - (this would be a one off task) - something like :

        private void AddSectionToGroup(string groupAlias, string sectionAlias)
        {
            var group = userService.GetUserGroupByAlias(groupAlias);
            if (group != null)
            {
                if (!group.AllowedSections.Contains(sectionAlias))
                {
                    group.AddAllowedSection(sectionAlias);
    
                    try
                    {
                        userService.Save(group);
                    }
                    catch (Exception ex)
                    {
                           // oh dear :( it went wrong
                    }
                }
            }
        }
    

    Kevin

  • Kristoffer Lindén 12 posts 122 karma points
    Jul 08, 2019 @ 13:35
    Kristoffer Lindén
    0

    Thanks Kevin, works just perfect!

    /Kristoffer

Please Sign in or register to post replies

Write your reply to:

Draft