I tried this approach to extend the functionality of the pipeline Sitecore.Pipelines.RenderField.GetTextFieldValue
- Extracted the code from the DLL and created my custom class like below.
TokenReplacer
namespace CMS.Feature.Replacer
{
public class TokenReplacer
{
public void Process(RenderFieldArgs args)
{
Assert.ArgumentNotNull((object)args, nameof(args));
this.EncodeFieldValue(args);
string fieldTypeKey = args.FieldTypeKey;
if (!fieldTypeKey.Equals("text", StringComparison.InvariantCulture) && !fieldTypeKey.Equals("single-line text", StringComparison.InvariantCulture))
return;
args.WebEditParameters.Add("prevent-line-break", "true");
}
protected virtual void EncodeFieldValue(RenderFieldArgs args)
{
Assert.ArgumentNotNull((object)args, nameof(args));
if (!Settings.Rendering.HtmlEncodedFieldTypes.Contains(args.FieldTypeKey))
return;
args.Result.FirstPart = HttpUtility.HtmlEncode(args.Result.FirstPart);
}
}
}
- Created a patch file and put it into the below location.
wwwroot<solution-root-directory>\App_Config\Include\zzz\TokenReplacer.config
<?xml version="1.0" encoding="utf-8" ?>
<configuration xmlns:x="http://www.sitecore.net/xmlconfig/">
<sitecore>
<pipelines>
<renderField>
<processor x:after="*[@type='Sitecore.Pipelines.RenderField.GetTextFieldValue, Sitecore.Kernel']" type="CMS.Feature.Replacer.TokenReplacer, CMS.Feature.Replacer" />
</renderField>
</pipelines>
</sitecore>
</configuration>
And I was able to get the single-line-text field type in my code.
And also the token like below.
Try this and update if you find any issue.