Skip to content

Commit 265f99c

Browse files
authored
Merge pull request #3 from Gibe/feature/readme
Add readme
2 parents c4c3c31 + c816ada commit 265f99c

File tree

2 files changed

+108
-14
lines changed

2 files changed

+108
-14
lines changed

.github/README.md

Lines changed: 47 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,66 @@
1-
# Models Builder .Property Override
1+
# Umbraco.Community.ModelsBuilder.PropertyOverride
22

33
[![Downloads](https://img.shields.io/nuget/dt/Umbraco.Community.ModelsBuilder.PropertyOverride?color=cc9900)](https://www.nuget.org/packages/Umbraco.Community.ModelsBuilder.PropertyOverride/)
44
[![NuGet](https://img.shields.io/nuget/vpre/Umbraco.Community.ModelsBuilder.PropertyOverride?color=0273B3)](https://www.nuget.org/packages/Umbraco.Community.ModelsBuilder.PropertyOverride)
55
[![GitHub license](https://img.shields.io/github/license/Gibe/Umbraco.Community.ModelsBuilder.PropertyOverride?color=8AB803)](../LICENSE)
66

7-
TODO: describe your package
7+
This package re-introduces functionality for overriding ModelsBuilder property implementations that was lost in Umbraco 9+.
88

9-
<!--
10-
Including screenshots is a really good idea!
9+
Umbraco versions 13.x - 15.x are supported.
1110

12-
If you put images into /docs/screenshots, then you would reference them in this readme as, for example:
11+
Properties can be marked up with a re-implemented `[ImplementPropertyType("alias")]` attribute, which causes them to be ignored when generating models through the default ModelsBuilder.
1312

14-
<img alt="..." src="https://github.com/Gibe/Umbraco.Community.ModelsBuilder.PropertyOverride/blob/develop/docs/screenshots/screenshot.png">
15-
-->
13+
In addition, classes can be marked up with `[ImplementAllPropertyTypes]`, which causes all properties on the class to be ignored, this is functionally equivalent to adding `[ImplementPropertyType("alias")]` to every property on the class.
14+
15+
Legacy (Umbraco 8.x) documentation for the `[ImplementPropertyType("alias")]` attribute can be found [here](https://our.umbraco.com/Documentation/Reference/Templating/Modelsbuilder/Control-Generation-vpre8_5#implement-property-type).
16+
17+
## Examples
18+
19+
`[ImplementPropertyType("alias")]` to ignore properties on an individual basis:
20+
21+
```
22+
using Umbraco.Cms.Infrastructure.ModelsBuilder;
23+
24+
namespace ModelsBuilder.PropertyOverride.TestSite.Models
25+
{
26+
public partial class Home
27+
{
28+
[ImplementPropertyType("content")]
29+
public global::Umbraco.Cms.Core.Models.Blocks.BlockListModel Content => this.Value<global::Umbraco.Cms.Core.Models.Blocks.BlockListModel>(_publishedValueFallback, "content");
30+
31+
[ImplementPropertyType("title")]
32+
public virtual string Title => this.Value<string>(_publishedValueFallback, "title");
33+
}
34+
}
35+
```
36+
37+
`[ImplementAllPropertyTypes]` to ignore all properties:
38+
39+
```
40+
using Umbraco.Cms.Infrastructure.ModelsBuilder;
41+
42+
namespace ModelsBuilder.PropertyOverride.TestSite.Models
43+
{
44+
[ImplementAllPropertyTypes]
45+
public partial class HomePageBlock
46+
{
47+
public virtual global::Umbraco.Cms.Core.Models.MediaWithCrops Image { get; set; }
48+
public virtual string SubTitle { get; set; }
49+
public virtual string Title { get; set; }
50+
}
51+
}
52+
```
1653

1754
## Installation
1855

19-
Add the package to an existing Umbraco website (v13+) from nuget:
56+
Add the package to an existing Umbraco website (Umbraco 13+) from nuget:
2057

2158
`dotnet add package Umbraco.Community.ModelsBuilder.PropertyOverride`
2259

23-
TODO *provide any other instructions for someone using your package*
24-
2560
## Contributing
2661

27-
Contributions to this package are most welcome! Please read the [Contributing Guidelines](CONTRIBUTING.md).
62+
Contributions to this package are most welcome!
2863

2964
## Acknowledgments
3065

31-
TODO
66+
[tristanjthompson](https://github.com/tristanjthompson) & [zade107](http://github/zade107)

docs/README_nuget.md

Lines changed: 61 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,65 @@
22

33
[![Downloads](https://img.shields.io/nuget/dt/Umbraco.Community.ModelsBuilder.PropertyOverride?color=cc9900)](https://www.nuget.org/packages/Umbraco.Community.ModelsBuilder.PropertyOverride/)
44
[![NuGet](https://img.shields.io/nuget/vpre/Umbraco.Community.ModelsBuilder.PropertyOverride?color=0273B3)](https://www.nuget.org/packages/Umbraco.Community.ModelsBuilder.PropertyOverride)
5-
[![GitHub license](https://img.shields.io/github/license/Gibe/Umbraco.Community.ModelsBuilder.PropertyOverride?color=8AB803)](https://github.com/Gibe/Umbraco.Community.ModelsBuilder.PropertyOverride/blob/main/LICENSE)
5+
[![GitHub license](https://img.shields.io/github/license/Gibe/Umbraco.Community.ModelsBuilder.PropertyOverride?color=8AB803)](../LICENSE)
66

7-
TODO: describe your package for nuget audience
7+
This package provides functionality for overriding Models Builder property implementations.
8+
9+
Umbraco versions 13.x - 15.x are supported.
10+
11+
Properties can be marked up with a re-implemented `[ImplementPropertyType("alias")]` attribute, which causes them to be ignored when generating models through the default Models Builder.
12+
13+
In addition, classes can be marked up with `[ImplementAllPropertyTypes]`, which causes all properties on the class to be ignored, this is functionally equivalent to adding `[ImplementPropertyType("alias")]` to every property on the class.
14+
15+
Legacy (8.x) documentation for the `[ImplementPropertyType("alias")]` attribute can be found [here](https://our.umbraco.com/Documentation/Reference/Templating/Modelsbuilder/Control-Generation-vpre8_5#implement-property-type).
16+
17+
## Examples
18+
19+
`[ImplementPropertyType("alias")]` to ignore properties on an individual basis:
20+
21+
```
22+
using Umbraco.Cms.Infrastructure.ModelsBuilder;
23+
24+
namespace ModelsBuilder.PropertyOverride.TestSite.Models
25+
{
26+
public partial class Home
27+
{
28+
[ImplementPropertyType("content")]
29+
public global::Umbraco.Cms.Core.Models.Blocks.BlockListModel Content => this.Value<global::Umbraco.Cms.Core.Models.Blocks.BlockListModel>(_publishedValueFallback, "content");
30+
31+
[ImplementPropertyType("title")]
32+
public virtual string Title => this.Value<string>(_publishedValueFallback, "title");
33+
}
34+
}
35+
```
36+
37+
`[ImplementAllPropertyTypes]` to ignore all properties:
38+
39+
```
40+
using Umbraco.Cms.Infrastructure.ModelsBuilder;
41+
42+
namespace ModelsBuilder.PropertyOverride.TestSite.Models
43+
{
44+
[ImplementAllPropertyTypes]
45+
public partial class HomePageBlock
46+
{
47+
public virtual global::Umbraco.Cms.Core.Models.MediaWithCrops Image { get; set; }
48+
public virtual string SubTitle { get; set; }
49+
public virtual string Title { get; set; }
50+
}
51+
}
52+
```
53+
54+
## Installation
55+
56+
Add the package to an existing Umbraco website (v13+) from nuget:
57+
58+
`dotnet add package Umbraco.Community.ModelsBuilder.PropertyOverride`
59+
60+
## Contributing
61+
62+
Contributions to this package are most welcome!
63+
64+
## Acknowledgments
65+
66+
[tristanjthompson](https://github.com/tristanjthompson) & [zade107](http://github/zade107)

0 commit comments

Comments
 (0)