Hey Christian, the problem is that native properties (Id, Level, CreateDate, etc) do not sort at the moment because of a bug, this has been solved in recent commits to the 4.7.1 branche. You can download and build it yourself, it's very stable and I am going live with that code tomorrow.
I've tried to download your build (set 2069) and the latest nightly (4.7.0.381).
The OrderBy sorting bug disappeared, but there are other issue in these both new builds - the doctype and mediatype property pages in the admin console are show nothing at all except tab headers :-(
Do you meet this issue in the latest builds? I should say here, that my current installation is not clear 4.7 but upgraded 4.6.1. Maybe my problem reasons are here...
Maybe there is an short guide to rebuild only one library (i think MacroEngine or...?) with this sort fix only? The current project is very close to production stage and native properties sotring feature is very important.
If you can revert to your previous version and the property pages work again, then do that. All you really need is in deed the MacroEngines dll. But this problem really can't be because of the upgrade to the nightly build because I think nothing except for the MacroEngines dll was changed. I don't know what the problem in your case is though.
The PDB files are there, why not hit CTRL+ALT+P in Visual Studio and attaching to the worker process for your site and see what exceptions are being thrown, you might find the problem soon enough.
My guess is that it's an incompatible datatype that's causing problems.
After I reverted the bin folder content to its original 4.7.0 state and replaced the MacroEngines.dll with the one from your build (earliaer in this thread), the both problems are gone. Now the normal work with the doctypes is possible and the items are sorted properly (I've used "sortOrder desc" by the way).
Very strange! What did you do to upgrade? Just overwriting the /bin folder should've been enough.
That said, this is a nightly and there might be work in progress that I'm not aware of, but I didn't have this issue with my sites (2 of which upgraded from 4.6) at all.
when I did my upgrade to 4.7 - it was a typical set of steps - /bin, /umbraco and /umbraco_client folders. Moreover, I've removed the version parameter value from the web.config to enforce the install/upgrade procedure, which was ended up with nothing special as far as I can see.
What about doctype editor problem - this strange behavior I can see with both your and 381 nightly build /bin folders. The normal behavior - with 4.7.0 original /bin only. Maybe the content of the /umbraco folder from your package should do the trick? (some aspx|ascx files are newer?)...
Anyway, the fully original /bin from 4.7.0 with only one updated MacroEngines.dll from your package solves my problems at the moment :-)
BTW, the full /bin folder from your package with PDB files and Visual Studio and working process attachment was showing absolutly nothing for me. I use in my dev process the manually started file-mode IIS Express at the moment - maybe this is the reason...
the nodetypealias of the blog called "Blog" with a capital B. i did replace the dll with the one in the zip. and you're right about the year, i'm trying to get an Archive blog by the years i'm getting 2010, 2011 and not 2011, 2010
Alright, I've just tried your code and it works just fine for me (with the same updated build that your using). So I think the MacroEngines.dll was not updated correctly for you.
For now the only solution I have would be the code below. Please report this on CodePlex, seems like a bug to me!
@using umbraco.MacroEngines @{ var nodes = new List<DynamicNode>(); foreach (dynamic dateFolder in Model.AncestorOrSelf("BlogOverview").Children) { nodes.Add(dateFolder); } foreach(var node in nodes.OrderBy(x => x.Name)) { <span>@node.Name</span> } }
Just found this thread as I was having the same problem. There is a way around getting sorting to work on native properties in 4.7 by using the @CurrentModel object instead of @Model. That way you can do this:
foreach (var dateFolder in @CurrentModel.AncestorOrSelf("Blog").Descendants().Items.OrderByDescending(i => i.Name)) { }
OrderBy not working?
Hi
I can't get the .OrderBy to work in umbraco v 4.7.0
What is wrong?
is it working and you're getting a wrong output or it's not working because an error?
i can't see something wrong with the code.
did you reference the @inherits umbraco.MacroEngine ???
and ensure that your razorcode is embed into @{}
Example
@{
@foreach() {}
}
I do not get any error, just wrong output. Adding desc does not change the order. The order in the output is taken from the sort order in Umbraco.
This is my full test scripts:
With my sample data I always get:
Hey Christian, the problem is that native properties (Id, Level, CreateDate, etc) do not sort at the moment because of a bug, this has been solved in recent commits to the 4.7.1 branche. You can download and build it yourself, it's very stable and I am going live with that code tomorrow.
I still have a build up over here if you don't want to build it yourself.
Hi Sebasiaan,
I've tried to download your build (set 2069) and the latest nightly (4.7.0.381).
The OrderBy sorting bug disappeared, but there are other issue in these both new builds - the doctype and mediatype property pages in the admin console are show nothing at all except tab headers :-(
Do you meet this issue in the latest builds? I should say here, that my current installation is not clear 4.7 but upgraded 4.6.1. Maybe my problem reasons are here...
Maybe there is an short guide to rebuild only one library (i think MacroEngine or...?) with this sort fix only? The current project is very close to production stage and native properties sotring feature is very important.
Thanks in advance :-)
If you can revert to your previous version and the property pages work again, then do that. All you really need is in deed the MacroEngines dll. But this problem really can't be because of the upgrade to the nightly build because I think nothing except for the MacroEngines dll was changed. I don't know what the problem in your case is though.
The PDB files are there, why not hit CTRL+ALT+P in Visual Studio and attaching to the worker process for your site and see what exceptions are being thrown, you might find the problem soon enough.
My guess is that it's an incompatible datatype that's causing problems.
Sebastiaan,
thank you for the explicitly pointed dll.
After I reverted the bin folder content to its original 4.7.0 state and replaced the MacroEngines.dll with the one from your build (earliaer in this thread), the both problems are gone. Now the normal work with the doctypes is possible and the items are sorted properly (I've used "sortOrder desc" by the way).
Thanks again.
Very strange! What did you do to upgrade? Just overwriting the /bin folder should've been enough.
That said, this is a nightly and there might be work in progress that I'm not aware of, but I didn't have this issue with my sites (2 of which upgraded from 4.6) at all.
Sebastiaan,
when I did my upgrade to 4.7 - it was a typical set of steps - /bin, /umbraco and /umbraco_client folders. Moreover, I've removed the version parameter value from the web.config to enforce the install/upgrade procedure, which was ended up with nothing special as far as I can see.
What about doctype editor problem - this strange behavior I can see with both your and 381 nightly build /bin folders. The normal behavior - with 4.7.0 original /bin only. Maybe the content of the /umbraco folder from your package should do the trick? (some aspx|ascx files are newer?)...
Anyway, the fully original /bin from 4.7.0 with only one updated MacroEngines.dll from your package solves my problems at the moment :-)
BTW, the full /bin folder from your package with PDB files and Visual Studio and working process attachment was showing absolutly nothing for me. I use in my dev process the manually started file-mode IIS Express at the moment - maybe this is the reason...
Alexander, i've tried the solution of replacing the MacroEngines.dll but it won't work, did you do something else to make it work?
i'm trying to do
What is not working about this?
Is the nodetypeALIAS of the blog called "Blog" with a capital B? Did you replace the MacroEngines.dll with the one in the zip file I posted?
Just checking: You're probably trying to get the folders by year right?
the nodetypealias of the blog called "Blog" with a capital B. i did replace the dll with the one in the zip.
and you're right about the year, i'm trying to get an Archive blog by the years
i'm getting 2010, 2011 and not 2011, 2010
So what's not working?
i'm not getting the order i want
i want to get
2011
2010
instead i get
2010
2011
Alright, I've just tried your code and it works just fine for me (with the same updated build that your using). So I think the MacroEngines.dll was not updated correctly for you.
For now the only solution I have would be the code below. Please report this on CodePlex, seems like a bug to me!
@using umbraco.MacroEngines
@{
var nodes = new List<DynamicNode>();
foreach (dynamic dateFolder in Model.AncestorOrSelf("BlogOverview").Children)
{ nodes.Add(dateFolder); }
foreach(var node in nodes.OrderBy(x => x.Name))
{ <span>@node.Name</span> }
}
now i see there's already a report about it http://umbraco.codeplex.com/workitem/30198
I hope it will be fixed in 4.7.1
I will try your solution, thank you for you help :)
Just found this thread as I was having the same problem. There is a way around getting sorting to work on native properties in 4.7 by using the @CurrentModel object instead of @Model. That way you can do this:
Just remember to add
.
thanks dan, i will try it.
Just a heads up, 4.7.1 will be out soon (possibly early July) and this should not be a problem any more.
is working on a reply...