Skip to main content
Logo
There is a newer version of Contensis. Click to find out more and download the latest version.

Use the NodeQuery object

This article takes you through and documents all of the functionality of the NodeQuery object used within Propertied Razor Views.

What is a node?

A node is any piece of content within your system, folders, pages, templates, PDF's, Images, everything stored within Contensis is a node. A node query gives you the ability to select a node from your system to be used within your propertied Razor views.

How do I write nodeQueries?

nodeQueries take the following format.

Can I have subqueries too?

Yes! Here's an example of the syntax which will be added inbetween the <nodequery> and </nodequery> tags. You can see in this example we have access to the @Request parameters on the current HTTP request.

Properties

We have a list of property references when inputting property names in the property in the query. We have also included some other properties to make life easier for you and the following are preferred properties.

  • FullPath
  • ID
    • @Node
    • @NodeID
  • IncludeInAtoZ
    • @Node.IncludeInAtoZ
    • true
    • false
  • IncludeInMenu
    • @Node.IncludeInMenu
    • true
    • false
  • IncludeInSearch
    • @Node.IncludeInSearch
    • true
    • false
  • IncludeInSiteMap
    • @Node.IncludeInSiteMap
    • true
    • false
  • Language
    • @Node.Language
    • Named language string e.g. en-gb
  • ModifiedDateTime
    • @Node.ModifiedDateTime
    • @Now
  • Name
  • Parent
    • @FolderNode
    • Folder ID
  • ParentID (alias of Parent)
  • Path
    • @Node.Path
    • Named path e.g. 'images/'
  • PublishedDateTime
    • @Node.PublishedDateTime
    • @Now
  • Size
  • Title
  • Type
    • @TemplateNode
    • News
    • Folder ID
    • Content Type ID
  • TypeID
  • ThumbnailUrl

Metadata

You can also query on metadata by using Data.MD_<metadata_name> format. This enables you to find pages with a specific metadata present for grabbing only news articles, for example.

Operators

Contains

Example: only allow the user to select nodes with Page in the title.

DoesNotContain

Example: only allow the user to select nodes without Page in the title.

IsEqualTo

Example: only allow the user to select nodes in English.

IsNotEqualTo

Example: only allow the user to select nodes in any language other than English.

StartsWith

Example: only allow the user to select nodes in the site-elements folder.

EndsWith

Example: only allow the user to select nodes that end with .js (JavaScript files).

GreaterThan

Example: only allow the user to select nodes that have a folder ID higher than 1024.

LessThan

Example: only allow the user to select nodes that have a folder ID lower than 2048.

GreaterThanOrEqualTo

Example: only allow the user to select nodes that have a folder ID higher than or equal to 1024.

LessThanOrEqualTo

Example: only allow the user to select nodes that have a folder ID lower than or equal to 2048.

IsEmpty

Example: only allow the user to select nodes that are not synchronised.

IsNotEmpty

Example: only allow the user to select nodes that are synchronised.

IsNull

Example: only allow the user to select nodes that are synchronised.

IsNotNull

Example: only allow the user to select nodes that are synchronised.

In

Example: only allow the user to select nodes that are in a certain folder (node ID).

NotIn

Example: only allow the user to select nodes that are not in a certain folder (node ID).

IsHomePage

Example: only allow the user to select nodes that are homepages.

IsWebPage

Example: only allow the user to select nodes that are webpages. 

Optional Attributes

orderby

You can use the orderby attribute in the following format:

orderby="Property_DatePublished desc"

You can use either asc or desc and any of the table column titles to order by.

Accessing Razor view properties

You can also access the properties that you have set in the Razor view itself. Here is an example below.

@Properties.ContentNodeQuery6.IncludeInMenu

You can also use the WebAPI nodes methods. This gives you greater control over queries and other properties in your Razor views by opening the feature up to existing tools like our WebAPI.