4

We are experiencing sporadic issues with @RenderComponentField() in our Razor templates. It seems that sometimes it does not render the field, just an empty TCDL tag, even when there is content in the field.

I have not yet managed work out any pattern for when this is occurring, initially we thought it was just embedded schema fields, but now it's happening on the most basic top-level text fields. For example:

@RenderComponentField("Heading",0)

Changing the code to 'normal' syntax it works fine with the same content:

@Fields.Heading

Has anyone else experienced this, or have any idea what might be going on?

2

This doesn't sound right to me but looking at the source for RenderComponentField you have this:

/// <param name="fieldIndex">Index of this value for multi-valued fields starting at 1. Single-value fields simply use 1.</param>

Which claims the index is 1-based. This doesn't explain the intermittent behaviour though..

Here's the complete source

    /// <summary>
    /// Renders a component field embedded in a tcdl:ComponenField tag.
    /// </summary>
    /// <param name="fieldExpression">Reference to a field relative to the context component. For example Fields.MyEmbeddedSchema.MyField</param>
    /// <param name="fieldIndex">Index of this value for multi-valued fields starting at 1. Single-value fields simply use 1.</param>
    /// <returns>The rendered component field.</returns>
    public string RenderComponentField(string fieldExpression, int fieldIndex)
    {
        return _builtInFunctions.RenderComponentField(fieldExpression, fieldIndex);
    }
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.