I am new to Umbraco, and appreciate any help. I am using nuPickers for relating a school class with student document types. I have achived that where a class has a number of students.
But now, in the class template, I would like to know to query relations so that in the school class template I will be able to display all students of that class.
Querying Relations in Razor View
Hi,
I am new to Umbraco, and appreciate any help. I am using nuPickers for relating a school class with student document types. I have achived that where a class has a number of students.
But now, in the class template, I would like to know to query relations so that in the school class template I will be able to display all students of that class.
I am using Umbraco 7+
Appreciate any help.
thanks
Simon
Have a look at the GetRelations method of uQuery : http://our.umbraco.org/documentation/Reference/Querying/uQuery/Relations
Dave
Instead of hard coded IDs, how can I get the page ID?
@Model.Content.Id or @CurrentPage.Id
It is throwing an error that The name 'CurrentPage' does not exist in the current context
Ok Dave, I was not inherting from @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
Hi Dave,
What is the namespace/reference for Document, because I want to get Document By Id and use such properties?
thank you.
You can do @Umbraco.TypedContent(idofyournode).
Dave
What is the difference betwen @Umbraco.TypedContent(1112) and @Umbraco.Content(1112)?
Thanks
simon
TypedContent returns a strongly typed object of type IPublishedContent.
Content returns a dynamic object.
The same goes for @Model.Content and @CurrentPage
And what is the difference between strongly typed object and dynamic object in Umbraco?
With the strongly typed you have intellisense in visual studio.
I will try to explain the difference for getting a property of your content called "visual".
With the strongly typed object you will do :
@Model.Content.GetPropertyValue("visual")
With dynamic you will do
@CurrentPage.Visual.
The last one will try to call the first one under the hood and will fail if it can be found.
Dave
is working on a reply...