Hello,
I created a plugin under umbraco 7 with a custom section using trees.config but now I would like to migrate it under Umb 8 but can not find or I have to create my custom section in the new version the documentation on the subject is not not good
Thank you for your help.
Cédric
via code : you need to impliment ISection and append it to the Sections() collection in a Composition.
public class DashboardComposer : IUserComposer
{
public void Compose(Composition composition)
{
composition.Sections().Append<MyCustomSection>();
}
}
public class MyCustomSection : ISection
{
public string Alias => "mySection";
public string Name => "My Section Name";
}
[PluginController("KeziaApp")]
//[Umbraco.Web.Trees.Tree("KeziaApp", "KeziaAlias", "Kezia Parametres", sortOrder: 0)]
[Umbraco.Web.Trees.Tree("content", "KeziaAlias", "Kezia Parametres", sortOrder: 0)]
public class KeziaAppTreeController : TreeController
{
protected override MenuItemCollection GetMenuForNode(string id, FormDataCollection queryStrings)
{
// create a Menu Item Collection to return so people can interact with the nodes in your tree
var menu = new MenuItemCollection();
if (id == Constants.System.Root.ToInvariantString())
{
// root actions, perhaps users can create new items in this tree, or perhaps it's not a content tree, it might be a read only tree, or each node item might represent something entirely different...
// add your menu items here following the pattern of <Umbraco.Web.Models.Trees.ActionMenuItem,umbraco.interfaces.IAction>
menu.Items.Add<CreateChildEntity, ActionNew>(ui.Text("actions", ActionNew.Instance.Alias));
// add refresh menu item
menu.Items.Add<RefreshNode, ActionRefresh>(ui.Text("actions", ActionRefresh.Instance.Alias), true);
return menu;
}
// add a delete action to each individual item
menu.Items.Add<ActionDelete>(ui.Text("actions", ActionDelete.Instance.Alias));
return menu;
}
protected override TreeNodeCollection GetTreeNodes(string id, FormDataCollection queryStrings)
{
// check if we're rendering the root node's children
if (id == Constants.System.Root.ToInvariantString())
{
// you can get your custom nodes from anywhere, and they can represent anything...
Dictionary<int, string> favouriteThings = new Dictionary<int, string>();
favouriteThings.Add(1, "Import des produits de Kezia");
// create our node collection
var nodes = new TreeNodeCollection();
// loop through our favourite things and create a tree item for each one
foreach (var thing in favouriteThings)
{
// add each node to the tree collection using the base CreateTreeNode method
// it has several overloads, using here unique Id of tree item, -1 is the Id of the parent node to create, eg the root of this tree is -1 by convention - the querystring collection passed into this route - the name of the tree node - css class of icon to display for the node - and whether the item has child nodes
var node = CreateTreeNode(thing.Key.ToString(), "-1", queryStrings, thing.Value, "icon-presentation", false);
nodes.Add(node);
}
return nodes;
}
// this tree doesn't support rendering more than 1 level
throw new NotSupportedException();
}
}
Custom Section Umb 8
Hello, I created a plugin under umbraco 7 with a custom section using trees.config but now I would like to migrate it under Umb 8 but can not find or I have to create my custom section in the new version the documentation on the subject is not not good Thank you for your help. Cédric
Hi Cedric,
you can create a custom section in two ways with v8
via the package.manifest (in an app_plugin folder for your plugin): so you can add the following
via code : you need to impliment ISection and append it to the Sections() collection in a Composition.
thank you very much I will try
hello I still have a question about the creation of my tree. in V7 I had this code: but I have errors on
And :
my code :
Hi
the Tree Attribute has been updated a little.
Should work
the Actions have moved about a bit.
will get you a refresh node (built in from the Umbraco core).
my create action ended up looking like this
but that is partly because i am also setting a custom route for my create action.
and a for me delete looks like this :
thank you very much it works
Thanks for this, but then how do you close the dialog that gets openened? I tried the editorService.close() with no luck. Any ideas?
Thanks
is working on a reply...