Skip to content

Commit 5cce6c0

Browse files
committed
doc: Update README
1 parent e2f621b commit 5cce6c0

File tree

1 file changed

+91
-0
lines changed

1 file changed

+91
-0
lines changed

.github/README.md

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,94 @@
11
# Umbraco.Community.SimpleTrees
22

3+
[![Umbraco Marketplace](https://img.shields.io/badge/Umbraco-Marketplace-%233544B1?style=flat&logo=umbraco)](https://marketplace.umbraco.com/package/Umbraco.Community.SimpleTrees)
4+
[![License](https://img.shields.io/github/license/jcdcdev/Umbraco.Community.SimpleTrees?color=8AB803&label=License&logo=github)](https://github.com/jcdcdev/Umbraco.Community.SimpleTrees?tab=MIT-1-ov-file)
5+
[![NuGet Downloads](https://img.shields.io/nuget/dt/Umbraco.Community.SimpleTrees?color=cc9900&label=Downloads&logo=nuget)](https://www.nuget.org/packages/Umbraco.Community.SimpleTrees)
6+
[![Project Website](https://img.shields.io/badge/Project%20Website-jcdc.dev-jcdcdev?style=flat&color=3c4834&logo=data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxNiIgaGVpZ2h0PSIxNiIgZmlsbD0id2hpdGUiIGNsYXNzPSJiaSBiaS1wYy1kaXNwbGF5IiB2aWV3Qm94PSIwIDAgMTYgMTYiPgogIDxwYXRoIGQ9Ik04IDFhMSAxIDAgMCAxIDEtMWg2YTEgMSAwIDAgMSAxIDF2MTRhMSAxIDAgMCAxLTEgMUg5YTEgMSAwIDAgMS0xLTF6bTEgMTMuNWEuNS41IDAgMSAwIDEgMCAuNS41IDAgMCAwLTEgMG0yIDBhLjUuNSAwIDEgMCAxIDAgLjUuNSAwIDAgMC0xIDBNOS41IDFhLjUuNSAwIDAgMCAwIDFoNWEuNS41IDAgMCAwIDAtMXpNOSAzLjVhLjUuNSAwIDAgMCAuNS41aDVhLjUuNSAwIDAgMCAwLTFoLTVhLjUuNSAwIDAgMC0uNS41TTEuNSAyQTEuNSAxLjUgMCAwIDAgMCAzLjV2N0ExLjUgMS41IDAgMCAwIDEuNSAxMkg2djJoLS41YS41LjUgMCAwIDAgMCAxSDd2LTRIMS41YS41LjUgMCAwIDEtLjUtLjV2LTdhLjUuNSAwIDAgMSAuNS0uNUg3VjJ6Ii8+Cjwvc3ZnPg==)](https://jcdc.dev/umbraco-packages/simple-trees)
7+
8+
9+
This packages aims to help developers quickly put together Umbraco Trees using C#.
10+
11+
## Features
12+
13+
- C# custom tree creation
14+
- No javascript or umbraco-package.json files required
15+
- Supports both Views & View Components
16+
- Easy to define section permissions
17+
18+
## Quick Start
19+
20+
### Install Package
21+
22+
```csharp
23+
dotnet add package Umbraco.Community.SimpleTrees
24+
```
25+
26+
### Register Tree
27+
28+
By default, this will display in the content section.
29+
30+
```csharp title="ExampleTree.cs"
31+
using Umbraco.Cms.Core.Models;
32+
using Umbraco.Community.SimpleTrees.Models;
33+
34+
namespace Umbraco.Community.SimpleTrees.TestSite.Trees;
35+
36+
public class MyTree : SimpleTree
37+
{
38+
public override Task<PagedModel<ISimpleTreeItem>> GetTreeRootAsync(int skip, int take, bool foldersOnly)
39+
{
40+
var data = new List<ISimpleTreeItem>
41+
{
42+
CreateRootItem("James", Guid.NewGuid().ToString(), "icon-user"),
43+
CreateRootItem("Tim", Guid.NewGuid().ToString(), "icon-user"),
44+
};
45+
46+
return Task.FromResult(new PagedModel<ISimpleTreeItem>(data.Count, data));
47+
}
48+
49+
public override Task<PagedModel<ISimpleTreeItem>> GetTreeChildrenAsync(string entityType, string parentUnique, int skip, int take, bool foldersOnly) => Task.FromResult(EmptyResult());
50+
51+
public override string Name => "My Tree";
52+
}
53+
```
54+
55+
### Create Views
56+
57+
- Your views **must** go in `/Views/Trees`
58+
- You views **must** be the name of your tree entities
59+
- For example: `MyTree.cs` => `/Views/Trees/MyItem.cshtml` & `/Views/Trees/MyRoot.cshtml`
60+
61+
```csharp title="Views/Trees/MyItem.cshtml"
62+
@inherits Umbraco.Community.SimpleTrees.Web.SimpleTreeViewPage
63+
64+
<uui-box headline="This is a custom tree item">
65+
<div>
66+
<table>
67+
<thead>
68+
<tr>
69+
<th>Entity Type</th>
70+
<th>Unique</th>
71+
</tr>
72+
</thead>
73+
<tbody>
74+
<tr>
75+
<td>@Model.EntityType</td>
76+
<td>@Model.Unique</td>
77+
</tr>
78+
</table>
79+
</div>
80+
</uui-box>
81+
```
82+
83+
84+
85+
## Contributing
86+
87+
Contributions to this package are most welcome! Please visit the [Contributing](https://github.com/jcdcdev/Umbraco.Community.SimpleTrees/contribute) page.
88+
89+
## Acknowledgements (Thanks)
90+
91+
- LottePitcher - [opinionated-package-starter](https://github.com/LottePitcher/opinionated-package-starter)
92+
93+
394

0 commit comments

Comments
 (0)