Eric Bourland
asked on
Problem with duplicate SortOrders in child pages
Hi. I have coded myself into a corner. The problem: If I have two or more child pages that have the same SortOrder value, then only one of the child pages will display -- in my CMS, and in navigation. If I have four child pages with SortOrder "1", only one of them will display.
The solution I might implement is validation for the SortOrder field in the edit form. The value for SortOrder is entered in a text field:
<cfinput type="text" name="SortOrder" value="#editPage.SortOrder #" size="1" maxlength="2" />
I am thinking of solutions to ensure that a duplicate SortOrder value is not entered for a given data record, but the solutions seem cumbersome. (Eg. I could display a list of all child pages under a given parent, and their SortOrder values; then forbid entering those existing values in the SortOrder text field.) But I want to keep the edit interface as simple as possible for the user.
Maybe a much better solution is to just change my CMS and navigation menu to allow records with duplicate SortOrder values to display.
What do you think? How do you usually deal with duplicate SortOrder values?
Thank you for any advice.
Eric
The solution I might implement is validation for the SortOrder field in the edit form. The value for SortOrder is entered in a text field:
<cfinput type="text" name="SortOrder" value="#editPage.SortOrder
I am thinking of solutions to ensure that a duplicate SortOrder value is not entered for a given data record, but the solutions seem cumbersome. (Eg. I could display a list of all child pages under a given parent, and their SortOrder values; then forbid entering those existing values in the SortOrder text field.) But I want to keep the edit interface as simple as possible for the user.
Maybe a much better solution is to just change my CMS and navigation menu to allow records with duplicate SortOrder values to display.
What do you think? How do you usually deal with duplicate SortOrder values?
Thank you for any advice.
Eric
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
>>>You want to order by your sortOrder but group by your ID or maybe Title... something that you know will change with each menu item..
This was the key. Thank you as always, gdemaria.
Eric
This was the key. Thank you as always, gdemaria.
Eric
ASKER
>>>You want to order by your sortOrder but group by your ID or maybe Title... something that you know will change with each menu item..
Exactly. I discovered this after some experimentation. So, I set the sort order in the query, with the ORDER BY clause:
Open in new window
Then I use the CFOUTPUT GROUP attribute to sort not by SortOrder, but by PageTitle:
<!--- display record information --->
<cfoutput query="getPages" group="PageTitleLevel1">
(....display level 1 pages....)
<cfoutput group="pageTitleLevel2">
<cfif len(pageTitleLevel2)>
(....display level 2 pages....)
</cfif>
<cfoutput group="PageTitleLevel3">
<cfif len(PageTitleLevel3)>
(....display level 3 pages....)
</cfif>
</cfoutput>
</cfoutput>
</cfoutput>
That seems to work, and the pages are sorted by PageTitle, then by SortOrder.
I'll close this question in a while; thank you as always. You are my ColdFusion spirit guide. =)
My next task is to set up a way to allow users to easily move, for example, a child page under one parent to become a grandchild page under another child page. I'm working on some ideas for that; it is an interesting challenge.
Hope your day is going well.
Eric