Portal Engine Questions on portal engine and web parts.
Version 7.x > Portal Engine > Using ClassNames on macro method View modes: 
User avatar
Member
Member
bryson.justus-chickasaw - 2/11/2013 3:58:12 PM
   
Using ClassNames on macro method
What is the proper use of the ClassNames method?

I am trying to count the number of children of a document that are of a specific doctype.

I tried CurrentDocument.Children.ClassNames("CMS.File").Count but it seems to count all of the Chiildren and not just children with the className of CMS.File.

So what is the proper usage for .ClassNames?

User avatar
Certified Developer 13
Certified Developer 13
kentico_josefd - 2/12/2013 3:42:34 AM
   
RE:Using ClassNames on macro method
Hello,

Unfortunately, I was unable to reproduce the issue. I have created a parent document -- Page (menu item) -- with three child documents: two of type File and one of type Page (menu item). Afterwards I have placed the following macro into static html web part on the parent document:
<h1> {% CurrentDocument.Children.ClassNames("CMS.File").Count %} </h1>

The web part correctly showed "2" when viewed. Is there anything you have done differently? Thank you.

Regards,
Josef Dvorak

User avatar
Member
Member
bryson.justus-chickasaw - 2/12/2013 9:01:35 AM
   
RE:Using ClassNames on macro method
Well I have been doing some testing and the macro works for only one instance per template.

If I put:
{% CurrentDocument.Children.ClassNames("CMS.MenuItem").Count %}

I get the same count for both macros. So if the CurrentDocument has 7 CMS.MenuItem children both of the above macros returns 7.

I have tested this in the same webpart and being in multiple webparts. Whatever macro get ran first all the rest return its value.

Is there a way to avoid this from taking place?

User avatar
Certified Developer 13
Certified Developer 13
kentico_josefd - 2/14/2013 3:14:43 AM
   
RE:Using ClassNames on macro method
Hello,

I have consulted this with our development team. Regrettably, this seems to be a bug in the current version. I'm very sorry for this inconvenience. We will attempt to fix this issue in the next week's hotfix package (.21) for this particular Kentico CMS version.

Regards,
Josef Dvorak