Yes, this is possible. There is an easy way to extend/add logic which is missing by implementing custom Variant Token.
This is an example implementation of ResolveParentName
processor:
public class ResolveParentName : ResolveVariantTokensProcessor
{
public override string Token => "$parentName";
public override void ResolveToken(ResolveVariantTokensArgs args)
{
// this if statement is quite important in order to support this token in JSON Variants
if (args.ResultControl != null)
{
args.ResultControl.Controls.Add(new LiteralControl
{
Text = args.ContextItem.Parent.Name
});
}
else
{
args.Result = args.ContextItem.Parent.Name;
}
}
}
Do not forget about registering this processor:
<pipelines>
<resolveVariantTokens>
<processor type="YOUR_NAMESPAVE.ResolveParentName, YOUR_ASSEMBLY" resolve="true" />
</resolveVariantTokens>
</pipelines>
Here is an example usage:
As you can see this is a great place to add a lot of custom logic and extend Rendering Variants. In the above example, I'm just using one args.ContextItem.Parent.Name
property but you can do whatever you need there.
UPDATE: Please use lowercased token names (instead of $parentName
go with $parentname
)