In this tutorial, you will learn about some of the different Umbraco API that you will need to know about in order to build a website using Umbraco CMS. This post is meant to be a quick reference guide to frequently used Umbraco queries. If you have any to add please leave a comment.
How To Get The Current Page Id
There are several ways to get the current page ID, directly from the context:
Within the view you would add:
After you get the current page Id, you will probably want to get a copy of the current document. To remind you, the document type is used when you want to get the data stored against a document type inside the database. A node, on the other hand, will return the data which has been published and cached. So, to get the current document we use:
To get the current Node, we use:
Now if you are using a Surface Controller, you can make life a little easier, by using:
How To Get The Current Pages Document Type in Umbraco
To get the current pages document type, you can use:
How To Get All Siblings from the Current Page
If you want to get all of the current page siblings in Razor we can use: