Watch video

You will learn how to query Umbraco data using the Razor Syntax. 
It is important that you are familiar with Razor Syntax. In this first chapter, you will take a look at the CurrentPage object.

As it was mentioned in the Razor Syntax chapter, Razor will be mainly used to query and transform Umbraco data into markup that you wish. You have already used the @Umbraco.Field("bodytext") helper, which gets inserted when you insert the Umbraco search field dialog. However, this is only a helper method to access the current page data. **There is no way of traversing. **You can't access the parent of the page, the child pages and so on.

Instead, when you are writing Razor code, you will look at the CurrentPage object. 
This object is available on your templates. It holds the data of the current page and it also allows you to traverse. You can access the parent page, the ancestors, child pages and so on.

It is important to know that the the CurrentPage object is of the type DynamicPublishedContent - it should make it easy to query published Umbraco data with a very short syntax. It has very useful properties, methods and shortcuts to access the Umbraco data.

For full details on the *CurrentPage object, you *can find some documentation on our.umbraco.org - if you go to Documentation, you will find some info on the DynamicPublisheddocument object.

In the following chapters, you will be using the** CurrentPage object** to write several code snippets.

Let's review this chapter.

  • The CurrentPage object allows you to query Umbraco data in your templates.

Querying Umbraco data with Razor

Total Time: 00:17:31

Learn how to access and query Umbraco data with Razor so you can write code that outputs navigations, breadcrumbs, sitemaps, lists of items, ...