c# - Use NVelocity with Sitecore FieldRenderer -


I have a field control over my web page which is bound to a sitcom item.

  Field Renderer ITEM = some citric waste; FieldRenderer.FieldName = "SomeField";  

Now some fields within a few SomeSitecoreItem token NVelocity content for example SomeField may contain the following markup:

  & lt; H1 & gt; $! Some tokens & lt; / H1> ;  

Is there a way to render! Can some tokens be replaced by the value associated with the code behind it?

You can add a step in the renderField pipeline:

  & Lt; Renderefield & gt; & Lt; Processor Type = "Sitecore.Pipelines.RenderField.SetParameters, Sitecore.Kernel" /> & Lt; Processor Type = "Sitecore.Pipelines.RenderField.GetFieldValue, Sitecore.Kernel" /> & Lt; Processor Type = "Sitecore.Pipelines.RenderField.GetTextFieldValue, Sitecore.Kernel" /> & Lt; Processor Type = "Sitecore.Pipelines.RenderField.ExpandLinks, Sitecore.Kernel" /> & Lt; Processor Type = "Sitecore.Pipelines.RenderField.GetImageFieldValue, Sitecore.Kernel" /> & Lt; Processor Type = "Sitecore.Pipelines.RenderField.GetLinkFieldValue, Sitecore.Kernel" /> & Lt; Processor Type = "Sitecore.Pipelines.RenderField.GetInternalLinkFieldValue, Sitecore.Kernel" /> & Lt; Processor Type = "Sitecore.Pipelines.RenderField.GetMemoFieldValue, Sitecore.Kernel" /> & Lt; Processor Type = "Sitecore.Pipelines.RenderField.GetDateFieldValue, Sitecore.Kernel" /> & Lt; Processor Type = "Sitecore.Pipelines.RenderField.GetDocxFieldValue, Sitecore.Kernel" /> & Lt; Processor Type = "Sitecore.Pipelines.RenderField.AddBeforeAndAfterValues, Sitecore.Kernel" /> & Lt; Processor Type = "Sitecore.Pipelines.RenderField.RenderWebEditing, Sitecore.Kernel" /> & Lt; Processor Type = "MyProject.ExpandNVelocityTokens, MyProject" /> & Lt; / RenderField & gt;  

code may look like:

  public class ExpandNVelocityTokens {public virtual void process (RenderFieldArgs args) {if (! (Shouldrun!); If ( ! Sitecore.Context.PageMode.IsPageEditorEditing) {args.Result.FirstPart = ExpandVelocityTokens (args.Result.FirstPart); Args.Result.LastPart = Vistarvivektikens (args.Result.LastPart);}} protected b (the cheapest possible way - Determine if we need to do something) Protected String ExpandVelocityTokens (string input) {// ... Make Velocity objects here}}  

Note: The pipeline is run for each field, so it is paramount that it is very fast - so shouldrun method to break out quickly, do nothing expensive here, unless you have to.

< / Div>

Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -