TokenManager: Rules Token

This is a post regarding a specific type of token used in the TokenManager, the Rendering Token.


Partial personalization is what it’s about.  More often than not you’ll want to take a single word or phrase in a paragraph and change it for personalization.  Out of the box sitecore only allows you to personalize on the item level, that leaves the majority of the text block left as duplicated content.  Duplicated content is the biggest no-no in the CMS world.

What does it do?

Executes a rules field with special actions to determine the value of the token.  Any rules are usable to build up your business logic.

How is it set up?

The Value field of the token is a Rules field instead of a rich text field.


There is an out of the box rules action for “Set token value to ______”.

Customization options

New actions can be easily implemented using a new RuleContext called TokenRuleContext.

namespace TokenManager.Rules
	public class SetTokenValue<T> : RuleAction<T>
		where T : TokenRuleContext
		public string Value { get; set; }

		public override void Apply(T ruleContext)
			ruleContext.Value = Value;

When the rules field is executed each rule block is run and whatever is left in the Value property of the TokenRuleContext at the end of the rule execution is injected into the page. This easily makes the rule token the most powerful token available.

Make sure to brush up on your Rules Engine.

Sample usage

When a user logs into, say a health insurance membership website, in the users session data you have the number of people in their family. You could create a rule condition “Where number of members of family is CONDITIONAL to INT”. At this point you can inject a token for “Member” if there’s only the one member in the plan or “Members” if there is more than one user.  Or even list the users out by first name if you create a custom action for it.