SDL Web 8 - Referencing General Configuration in RTF
I was recently working on a ticket whereby content is not reflected on the site after updating the target component.
This was a common enough problem I encountered in the past so I jumped into investigating the issue.
The setup is pretty standard. We have a page containing 3 components. One component has a template “Footnotes”. The component itself is a single Rich Text Field (RTF) field.
In the RTF, it only has:
[ExampleKey]
[ExampleKeyTwo]
[ExampleKeyThree]
These keys are from a component using General Configuration schema. Each key is then somehow transformed to the value of each of their corresponding.
I thought that this would be done through a Template Building Blocks (TBB). Either through the component template or the page template. But no luck. The component template did have a “Default Component Template Finish Action” which included “Resolve Rich Text” but this was for component linking.
I ran the component in Template Builder and the content in the output still had these placeholders suggesting it’s not done through SDL Web 8.
I had a look at the view (as the component template doesn’t have a controller reference) and the region and entity view isn’t doing anything except rendering markup.
I was pointed at the web.config where:
This is pretty nifty.
It inherits from BaseModelBuilder and IModelBuilder:
It uses the SubstantiationReplacement class to handle how Substantiation is updated.
The ITextReplace interface simply defines one method:
The Substantiations method is an extension method:
Final Thought
It’s an interesting approach. One I’ve not encountered before. By convention, you can define a simple workflow allowing content editors to use substitute a key of a key/value component and have its value rendered when the page is served.
This can also be used to handle other text replacement operations such as replacing a value of an attribute depending on content.
One thing I’ve encountered is that you must have a way of organizing your key/value pair components in a way that it’s easy to maintain by content editors. You must also be careful to ensure that no duplication are added in your keys.