8

The following is a simplified example: I have a Razor Mediator template and a parameter schema. The parameter schema "News Article Class" is attached to the Razor template and contains the mandatory field className. If I were using a DWT I would use the following code: "@@className@@" to print the contents of the field. How would I accomplish this on a Razor Mediator template?

1
  • Welcome Nicholas, to Tridion Stack Exchange. Nice clear question, thanks for asking and prompting some useful answers! :-) Commented Jun 23, 2015 at 17:41

2 Answers 2

8

You have three options to retrieve any values from the package, which would include parameter schemas:

@Package.ItemName

@Package.GetByName("ItemName").GetAsString()

@Package.GetValue("ItemName")

2
  • +1, I missed/forgot that the fields in parameters schemas get added to the Template Package. I ran across @FrankvanPuffelen's explanation on the parameter schema fields in templates for anyone wondering how they work. Commented Jun 23, 2015 at 17:47
  • One thing to note with getting values out of the package - they appear to be case sensitive. So unlike the Dynamic Item Fields where Fields.fieldName is the same as Fields.FieldName, when getting values out of the package, you have to use the same case as its name in the package.
    – J Stuart
    Commented May 23, 2018 at 19:22
4

And for regular fields, you can do something like this:

@Fields.className

For more info about Razor syntax, have a look at the documentation here:

https://code.google.com/p/razor-mediator-4-tridion/

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.