-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
39 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,40 @@ | ||
# CodeArt.Optimizely.PropertyInheritance | ||
An add-on for property inheritance in Optimizely CMS | ||
Add-on for Optimizely CMS 12 that enables property inheritance across content types. This solves a similar problem to the old (pre CMS 7) Dynamic Properties. | ||
If a property is not set on a page, it will fallback to inheriting from the ancestors. | ||
|
||
|
||
## Installation | ||
|
||
In order to start using property inheritacnce module you need to add it explicitly to your site. | ||
Please add the following statement to your Startup.cs | ||
|
||
```csharp | ||
public class Startup | ||
{ | ||
... | ||
public void ConfigureServices(IServiceCollection services) | ||
{ | ||
... | ||
services.AddPropertyInheritance(); | ||
... | ||
} | ||
... | ||
} | ||
``` | ||
|
||
## Usage | ||
In your models, add the following attribute to the properties you want to inherit: | ||
```csharp | ||
[Inherit(InheritIfNullOrEmpty = true,SearchAllAncestors =true)] | ||
public virtual string MyProperty { get; set; } | ||
``` | ||
The attribute has multiple properties: | ||
- SwitchPropertyName. A string with the name of a boolean property that indicates if the property should be inherited or not. If the property is not set, it will be inherited. | ||
- InheritIfNull. If true, the property will be inherited if it's null. | ||
- InheritIfNullOrEmpty. If true, the property will be inherited if it's null or empty. This is true by default | ||
- ParentPropertyToInheritFrom. The name of the property on the parent content to inherit from. If not set, the same property name will be used. | ||
- SearchAllAncestors. If true, the module will search all ancestors until it finds a value. If false, it will only search the direct parent. This is false by default. | ||
|
||
|
||
## Caution | ||
Note, there can be a slight performance penalty when using this module. |