ASPX templates
Version 7.x > ASPX templates > Dynamic data in Master Page Template View modes: 
User avatar
Member
Member
kyle.shankin-gmail - 8/29/2013 10:04:38 AM
   
Dynamic data in Master Page Template
I'm trying to count the number of a specific document type, and have that number appear in the header of my website. Is there a way to do this from within a master page?

User avatar
Kentico Support
Kentico Support
kentico_janh - 8/30/2013 6:11:50 AM
   
RE:Dynamic data in Master Page Template
Hello,

Since you are using the ASPX development mode, your master page is located as a physical file within your project folder and you can access its code-behind as well. In the code you can call for instance the CMS.DocumentEngine.TreeProvider.SelectNodes(String, String, String, Boolean, String) with following parameters:
siteName (String)
aliasPath (String)
cultureCode (String)
combineWithDefaultCulture (Boolean)
classNames (String)

As you can see, there is the className parameter where you can specify your document type.

Best regards,
Jan Hermann

User avatar
Member
Member
kyle.shankin-gmail - 9/4/2013 8:21:51 AM
   
RE:Dynamic data in Master Page Template
Hi Jan, Thanks for the reply!

These templates were built from within the CMS itself and I can't find the files in visual studio. Is there a specific area that I should be looking in?

User avatar
Kentico Support
Kentico Support
kentico_janh - 9/5/2013 5:56:01 AM
   
RE:Dynamic data in Master Page Template
Hello,

Oh ok, so you are not using the ASPX template approach (however you post this question the the ASPX part of our forum). In this case, you can take advantage of context macros:
{% Documents.Where("NodeClassID < 3441").Count %}

Where 3441 is the ClassID of required document type (you can find it in the CMS_Class table).

Best regards,
Jan Hermann

User avatar
Member
Member
kyle.shankin-gmail - 9/5/2013 9:21:24 AM
   
RE:Dynamic data in Master Page Template
Ah yes, I do apologize for my posting in the wrong area. I am new to Kentico and .net; I mixed up .aspx with .ascx :x

In any case, thank you for the response with the info about the context macro. That works perfectly!