I am trying to use the Count() function on a set of Children pages but am receiving an "Error loading Partial View" error. I'd like to set the Count() as a variable so I may use it in my html output. This is the code I have within the editor in Partial View Macro Files.
If I remove the selectioncount var and h3 line, the page renders fine, so it is clearly the Count() function that is giving me the error. I'm sure I am overlooking something simple as I am new to Umbraco. Thanks!
Thanks for your help. Your snippet yielded the same error. In order to simplify my troubleshooting, I cannot even get this snippet to properly output the Count().
@inherits Umbraco.Web.Macros.PartialViewMacroPage
@{
var selection = CurrentPage.Children.Where("Visible").OrderBy("CreateDate desc");
var selectioncount = selection.Count();
}
<h3>There are @selectioncount items</h3>
Count Function Within Macro Partial View
I am trying to use the Count() function on a set of Children pages but am receiving an "Error loading Partial View" error. I'd like to set the Count() as a variable so I may use it in my html output. This is the code I have within the editor in Partial View Macro Files.
If I remove the selectioncount var and h3 line, the page renders fine, so it is clearly the Count() function that is giving me the error. I'm sure I am overlooking something simple as I am new to Umbraco. Thanks!
Hi Lance and welcome to our :-)
Could you please try the code snippet below and see if this works for you.
Hope this helps,
/Dennis
Thanks for your help. Your snippet yielded the same error. In order to simplify my troubleshooting, I cannot even get this snippet to properly output the Count().
Any other ideas?
I just tried your simplified snippet on 7.3.8 and it didn't yield any errors.
Can you post the code of the page where you call your macro?
is working on a reply...