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?

  • Welcome Nicholas, to Tridion Stack Exchange. Nice clear question, thanks for asking and prompting some useful answers! :-) – Alvin Reyes Jun 23 '15 at 17:41
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")

  • +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. – Alvin Reyes Jun 23 '15 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 May 23 '18 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, privacy policy and cookie policy

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