ASPX templates
Version 6.x > ASPX templates > Sort order in CMSListMenu View modes: 
User avatar
Member
Member
fredrik-helium - 10/31/2011 3:04:50 AM
   
Sort order in CMSListMenu
Hi!

I have been trying to get a correct sort order for pages using the CMSListMenu which is being used as a sub menu (left menu).

I have a site tree structure (only part of it) like the one below:

Support
-News
-About us
-Contact us

My CMSListMenu control looks like this:

<cms:CMSListMenu DisplayOnlySelectedPath="true" ClassNames="*" OrderBy="NodeOrder" CheckPermissions="true" ID="SubMenu" DisplayHighlightedItemAsLink="true" Path="/{0}/%" runat="server" />

The problem I am experiencing is that my menu is rendered in the wrong order, like:

Support
-About us
-News
-Contact us

I thought that the OrderBy="NodeOrder" should solve this. It looks correct in the database in the CMS_Tree table, as the NodeOrder columns looks like this:

News - NodeOrder=1
About us - NodeOrder=2
Contact Us - NodeOrder=3

I'm sure I'm missing something trivial but not sure where to go next. Any hints?

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 10/31/2011 4:51:42 AM
   
RE:Sort order in CMSListMenu
Hi,

Could you please see this FAQ? It is not that simple to sort the order of the items :-) I hope it will help.

Best regards,
Juraj Ondrus

User avatar
Member
Member
fredrik-helium - 10/31/2011 5:39:51 AM
   
RE:Sort order in CMSListMenu
Thanks for the quick reply. I forgot to mention but I have actually tried this already (I found the tip in a forum post).

I just tried once again and there is no change between using "NodeLevel, NodeOrder, NodeName" and only "NodeLevel".

If I try to switch to something else, like "NodeName" or "NodeName, NodeLevel, NodeOrder" I do get different sorting results (by name) so the OrderBy IS taken into account, just I won't receive the resulting order I wish.

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 11/1/2011 12:10:07 AM
   
RE:Sort order in CMSListMenu
Hi,
The thing from the FAQ works for sure as it is.
What is the exact structure of the documents in your tree?

Is it exactly like:

-Parent
---child1
---child2
---child3

Or, are the documents on different levels with different parents?

Best regards,
Juraj Ondrus

User avatar
Member
Member
fredrik-helium - 11/2/2011 2:59:57 AM
   
RE:Sort order in CMSListMenu
Yes, it's exactly like that but I think I have figured out why it doesn't work.

If the structure is like this:

-Parent
---child1
---child2
---child3

and say that child1 and child3 is a regular "Page (menu item)" but child2 is a custom document type I have created myself.

In this case, child2 will always end up at the bottom. Is there a way to prevent this sort order to happen and sort everything according to NodeLevel, disregarding of the content type?

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 11/3/2011 7:00:26 AM
   
RE:Sort order in CMSListMenu
Hi,

It is strange. The order by expression mentioned in the FAQ works for sure. Moreover, I have created similar scenario as you have, I just used Page (menu item) document type together with News type.

Then, I am using this:

<cms:CMSListMenu DisplayOnlySelectedPath="true" ClassNames="CMS.MenuItem;CMS.News" CheckPermissions="true" ID="SubMenu" DisplayHighlightedItemAsLink="true" Path="./%" runat="server" />

I changed just the path and ClassNames (could you please list the class names as I do, I am not sure whether the * is working, usually to list all type is used this macro ##ALL##).

And it is working just fine even without the order by expression - I moved the documents around and their order in the content tree is always reflected on the live site too.

Is it possible for you to send us the site export package?

Best regards,
Juraj Ondrus

User avatar
Member
Member
john-craftedmedia - 3/19/2012 7:26:04 AM
   
RE:Sort order in CMSListMenu
Was anything resolved out of this?

I have the same scenario where the sort order for CMSListMenu first takes into account the ClassName.

So for different Document types, the first document type listed will be shown first (and then ordered by nodelevel, nodeorder properly), then the second and so on and so forth.

So I will have as an example:
+ gallery document type with node order 3
+ detail document type with node order 1
+ detail document type with node order 2
+ detail document type with node order 4
+ detail document type with node order 6
+ news document type with node order 5

If I re-order the list of document types, the menu is re-ordered accordingly to the above behaviour.

Looking at the profiler, it seems that multiple class names generate a query per class name ordered by nodelevel, nodeorder, which I guess is joined up in code one after the other without re-ordering.

John

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 3/25/2012 2:01:34 AM
   
RE:Sort order in CMSListMenu
Hi,

Could you please describe your exact setup and the web part configuration? I have just tired to add various document types into the content tree and I have used this setting for the List Menu:

<cms:CMSListMenu DisplayOnlySelectedPath="true" ClassNames="CMS.MenuItem;CMS.News;CMS.Article;CMS.Laptop;CMS.Cellphone;CMS.ImageGallery;CMS.Smartphone;CMS.Software" CheckPermissions="true" ID="SubMenu" DisplayHighlightedItemAsLink="true" Path="/%" runat="server" />


The listed document types are in the tree and I have created them in a random places. When I view the page with the menu, they are ordered accordingly even without the order by expressions "NodeLevel, NodeOrder, NodeName". When I move any document, the change is also visible in the menu (I had to clear the cache when viewing it on the live site).

Best regards,
Juraj Ondrus