3

Any idea how I can access the fields of an item inside the variant NVelocity template? I have code inside my variant template and I'm trying to read the template fields using @Html.Sitecore().Field("Field Title") but it's not working. Is there something I'm missing?

enter image description here

2 Answers 2

4

In a NVelocity template you can access the fields of the current context item with $item.Fields.FieldName where FieldName is the name of your field.

In this case, the space in your field name could become an issue. Not sure how to do that. But you could rename the field (dismiss the space) and give it a display name for the editors if you want them to see it with a space.

2
  • Thank you @Gatogordo for your help. yes, it works for me with fileds that has no space, however i need to apply this also to fields with spaces in the field name.Any clue?
    – AME
    Commented Jul 4, 2018 at 14:53
  • No.. I had this issue as well and renamed my field (and put the value with spaces in the title field so it appears the same to the content editors)
    – Gatogordo
    Commented Jul 4, 2018 at 14:55
3

Another option is to use $item.Fields.get_Item("Event title")

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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