The problem with it is that it uses XPathNodeIterator which gets all comments and displays them in the way that old comments are on the top and new comments are at the bottom. I (and I guess most of others) want to display latest comments on top.
Is it possible to iterate the collection backwards? Is there a way to sort comments somehow?
UComment and comments display order - razor
Hi guys,
I'm using UComment on my site and display the list of comments using razor code similar to the one shown here: http://our.umbraco.org/projects/collaboration/ucomment/using-ucomment/19347-UComment-and-Razor
The problem with it is that it uses XPathNodeIterator which gets all comments and displays them in the way that old comments are on the top and new comments are at the bottom. I (and I guess most of others) want to display latest comments on top.
Is it possible to iterate the collection backwards? Is there a way to sort comments somehow?
Thanks,
Zakhar.
Hi Zakhar,
I had the same problem, the solution I found was to use the XPathNavigator & Expression.
var title = Model.Name;
XPathNodeIterator nodesroot = XsltLibrary.GetCommentsForNode(HttpContext.Current.Request.RawUrl.GetHashCode());
XPathNavigator curnavigator = nodesroot.Current;
XPathExpression nodesexpr = XPathExpression.Compile("//comment");
nodesexpr.AddSort("@created", XmlSortOrder.Descending, XmlCaseOrder.None, "", XmlDataType.Text); XPathNodeIterator nodes = curnavigator.Select(nodesexpr);
int cnt = nodes.Count;
Hope this helps you out.
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.