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 ReyesCommented Jun 23, 2015 at 17:41
Add a comment
|
2 Answers
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. 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 StuartCommented May 23, 2018 at 19:22
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: