I was going to suggest the same thing as Tim. The InGroupsOf is an extension method within the "Umbraco.Core" namespace, so it's weird that the error is being thrown.
I'm wondering if it work with any other IEnumerable<T>?
e.g.
var groups = Enumerable.Range(1, 10).InGroupsOf(2);
Hmmm, I'm still confused about the "'System.Collections.Generic.List<Umbraco.Core.Models.IPublishedContent>' does not contain a definition for 'InGroupsOf'" error.
As the node should apply to any IEnumerable<T> extension method.
I'm wondering what would happen if you tried this...
var groups = Enumerable.Range(1, 10).ToList().InGroupsOf(2);
Sorry, I wasn't trying to suggest using ToList() on an existing List<T>.
Hmmm, ok, you could try doing it the other way around, calling the extension method directly...
var logos = CurrentPage.Site().GetPropertyValue<IEnumerable<IPublishedContent>>("footerlogo");
var groups = Umbraco.Core.EnumerableExtensions.InGroupsOf(logos, 2);
Getting nested content in groups?
I am trying to get my nested content in groups, but I can't figure out how to do this. This is my loop:
The code above returns the following error:
How would i render my nested content in groups?
If you add a @using Umbraco.Core statement to the top of the view, does it work?
If not, which version of Umbraco are you using please?
I've tried that. It didn't work.
EDIT: Forgot to mention, that I am running 7.2.8
I was going to suggest the same thing as Tim. The
InGroupsOf
is an extension method within the "Umbraco.Core" namespace, so it's weird that the error is being thrown.I'm wondering if it work with any other
IEnumerable<T>
?e.g. var groups = Enumerable.Range(1, 10).InGroupsOf(2);
See what happens then?
Cheers,
- Lee
That works!
This is my Stack Trace for the example in the first post of this thread:
Hi Søren,
Hmmm, it's a bit confusing why
InGroupsOf
would work for the number range, but not for the node list.Does the loop work if you remove the
InGroupsOf(2)
call from it?Does that throw an error?
After that, I'm not sure what else I can suggest :-(
Thanks,
- Lee
Hi Lee
Yes, that would work. This:
Would return this:
Hmmm, I'm still confused about the "
'System.Collections.Generic.List<Umbraco.Core.Models.IPublishedContent>' does not contain a definition for 'InGroupsOf'
" error.As the node should apply to any
IEnumerable<T>
extension method.I'm wondering what would happen if you tried this...
...
Feels like I'm clutching at straws now though :-(
Cheers,
- Lee
This would return the same as your first suggestion.
If apply this to my code, I get the following error:
Sorry, I wasn't trying to suggest using
ToList()
on an existingList<T>
.Hmmm, ok, you could try doing it the other way around, calling the extension method directly...
Then loop over the
groups
.That did the trick!
Thank you Lee!
LOL! Love the gif!
I still find it weird that the extension method didn't work (from your first code snippet), but glad that we eventually got there! :-)
Cheers,
- Lee
is working on a reply...