I was recently doing some token replacement of field values using a processor that I was adding to the RenderField pipeline. The problem was, it wasn’t running in Glass. Debugging in Visual Studio, the pipeline was never hit. Standard Sitecore rendering of the field was fine, but Glass – nope.
After much scratching of head and Googling, I found this on Github: https://github.com/mikeedwards83/Glass.Mapper/issues/98
So, for efficiency…
The renderField pipeline is only called during edit mode for all field types except Rich Text.
Good news though…
I think we added the field setting SitecoreFieldSettings.ForceRenderField which forces a string field to use the renderfield pipeline.
Right, so can we use that? Yes, we can. Here is an example model:
That causes the RenderField pipeline to run when Glass is rendering the Content field.
And suddenly my token replacement started working. It’s a bit of a pain having to tag all the relevant fields up with this ‘ForceRenderField’ attribute, but it’s pretty easy, and using a pipeline makes sense.