Glass, ForceRenderField, and the RenderField pipeline

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:

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.



Glass, ForceRenderField, and the RenderField pipeline

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.