This blog post describes an approach to managing paths to items semi dynamically in the Sitecore ASP.NET web Content Management System (CMS) and Experience Platform (XP). In this context, dynamic means using logic to control item paths when CMS users edit content, which is more dynamic than controlling item paths when users create items or move them, especially into a bucket.
In previous blog posts, I mentioned that:
Therefore, some implementations could benefit from a solution that intercepts item updates to:
We have at least three options for intercepting item updates:
When I first looked at this problem six months ago, I published a prototype for a condition to determine whether an item is in a bucket. We can use this with an action that applies bucketing path rules. That could look something like this:
ApplyBucketRules<T> : RuleAction<T>
where T : Sitecore.Rules.RuleContext
//TODO: separate action to apply rules defined in item
Item likeABucket = ruleContext.Item.Parent;
likeABucket = likeABucket.Parent;
" : Apply invoked for "
+ ruleContext.Item.Paths.FullPath +
" not in bucket"
For this I created the /sitecore/system/Settings/Rules/Definitions/Elements/Item Path/Apply Bucket Rules item from the System/Rules/Action template, set Text to apply bucket path rules, and set Type to Sitecore.Sharedsource.Rules.ItemPath.Actions.ApplyBucketRules,Sitecore.Sharedsource. Then I created the /sitecore/system/Settings/Rules/Item Saved/Rules/Apply Path Rules rule definition item from the System/Rules/Rule data template and bound the condition to the action.