Developer forum

Forum » Development » Create custom setting node in Settings section

Create custom setting node in Settings section

Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi guys,

I am wondering if it's possible to create a custom node in the settings section where I can add some custom modules configuration.

Or even a completely separate section like the Demo section I have noticed in Rapido 3.3.
Can I find documentation for these purposes somewhere?

Thank you,

Adrian


Replies

 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi guys,

Anybody?

Thank you,
Adrian

 
Nicolai Pedersen
Reply

Yes, see screendump and code.

You cannot create root level nodes and parent nodes should have at least one child

using Dynamicweb.Core.UI;
using Dynamicweb.Management.Actions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Dynamicweb.Management.Demo
{
    [Navigator("Settings/")]
    public class MySettingsNavigator : INavigator
    {
        private readonly Node Hello1Node;
        private readonly Node Hello2Node;
        private readonly Node Hello3Node;

        public MySettingsNavigator()
        {
            Hello1Node = new Node()
            {
                Id = "Hello1",
                HasNodes = false,
                HasActions = true,
                Icon = Core.UI.Icons.KnownIcon.AccountBalanceWallet,
                IconColor = KnownColor.Folder,
                Title = "Hello 1",
                DefaultAction = new OpenScreenAction("/Admin/Content/Management/EventViewer/EventViewerOverview.aspx"),
                Actions = new Core.UI.Actions.Action[]
                {
                    new OpenScreenAction("/Admin/Content/Management/EventViewer/EventViewerOverview.aspx")
                    {
                        Icon= Core.UI.Icons.KnownIcon.Facebook,
                        Title = "Facebook 1"
                    },
                    new OpenScreenAction("/Admin/Content/Management/EventViewer/EventViewerOverview.aspx")
                    {
                        Icon= Core.UI.Icons.KnownIcon.FacebookSquare,
                        Title = "Facebook 2"
                    }
                }
            };

            Hello2Node = new Node()
            {
                Id = "Hello2",
                HasNodes = false,
                HasActions = false,
                Icon = Core.UI.Icons.KnownIcon.BookmarkOutline,
                IconColor = KnownColor.Danger,
                Title = "Hello 2",
                DefaultAction = new OpenScreenAction("/Admin/Content/Management/EventViewer/EventViewerOverview.aspx"),
            };

            Hello3Node = new Node()
            {
                Id = "Hello3",
                HasNodes = false,
                HasActions = false,
                Icon = Core.UI.Icons.KnownIcon.TencentWeibo,
                IconColor = KnownColor.Modules,
                Title = "Hello 3",
                DefaultAction = new ShowMessageAction("Hello world!")
            };
        }

        public IEnumerable<Node> GetNodes(string path, IDictionary<string, string> requestParameters)
        {
            if (path == "System")
            {
                return new[] { Hello1Node, Hello2Node };
            }
            else if (path == "ControlPanel")
            {
                return new[] { Hello3Node };
            }
            return Enumerable.Empty<Node>();
        }

        public IEnumerable<Core.UI.Actions.Action> GetActions(string path, IDictionary<string, string> requestParameters)
        {
            if (path == Hello1Node.Id)
            {
                return Hello1Node.Actions;
            }
            if (path == Hello2Node.Id)
            {
                return Hello2Node.Actions;
            }
            if (path == Hello3Node.Id)
            {
                return Hello3Node.Actions;
            }
            return Enumerable.Empty<Core.UI.Actions.Action>();
        }
    }
}
Setting_nodes.png
 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi Nicolai,

Thank you very much. I will give it a try.


Adrian

 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi Nicolai,

One more question.

Can I place my code in CustomModules instead of :

/Admin/Content/Management/EventViewer/

?

Thank you,
Adrian

 
Nicolai Pedersen
Reply

Anywhere you want.

 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Awesome!

Thanks,
Adrian

 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi Nicolai, 

I need clarification on this issue.

By "root" node, do you mean in the left sidebar where we have Home, Content, Ecommerce etc?

I remember at some point there was a Demo root node with some logic in it. it was probably a left over from a development but still something custom.

Isn't there any way I can create a new section to place my custom functionality?

Thank you,

Adrian

 

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

You can implement your navigator with IArea:

 

[Navigator(SystemName)]
public class MySettingsNavigator : IArea, INavigator
{
    public const string SystemName = "Demo";

    public XElement Configuration { get; set; }

    public string Color { get; set; } = "black";

    public string Image { get; set; } = "home";

    public string Name { get; set; } = SystemName;

    public string Title { get; set; } = "Demo";
    public string DefaultAction { get; set; } = "/Admin/Blank.aspx";

}

 

You must be logged in to post in the forum