Skip to content

Commit

Permalink
Multiple updates
Browse files Browse the repository at this point in the history
  • Loading branch information
AThraen committed Jun 2, 2023
1 parent 58813fd commit 70a943b
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -396,3 +396,4 @@ FodyWeavers.xsd

# JetBrains Rider
*.sln.iml
/out/CodeArt.Optimizely.PropertyInheritance
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>CodeArt.Optimizely.PropertyInheritance</id>
<version>1.0.0</version>
<version>1.0.1</version>
<title>CodeArt.Optimizely.PropertyInheritance</title>
<authors>CodeArt Team</authors>
<owners>CodeArt Team</owners>
<owners>CodeArt Team / Open Source</owners>
<Company>CodeArt</Company>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>Addon that makes it easy to support property inheritance in Optimizely CMS</description>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class InheritAttribute : Attribute
/// <summary>
/// Inherit this value if it's null or empty
/// </summary>
public bool InheritIfNullOrEmpty { get; set; }
public bool InheritIfNullOrEmpty { get; set; } = true;

/// <summary>
/// Name of property on parent content to inherit from. Default is same name.
Expand Down
26 changes: 24 additions & 2 deletions src/CodeArt.Optimizely.PropertyInheritance/readme.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
CodeArt.Optimizely.PropertyInheritance

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

Expand All @@ -17,4 +20,23 @@ public class Startup
...
}
...
}
}

Usage
=====
In your models, add the following attribute to the properties you want to inherit:

[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.

0 comments on commit 70a943b

Please sign in to comment.