Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Problem with duplicate SortOrders in child pages

Posted on 2012-04-01
3
182 Views
Last Modified: 2012-06-21
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
0
Comment
Question by:Eric Bourland
  • 2
3 Comments
 
LVL 39

Accepted Solution

by:
gdemaria earned 500 total points
ID: 37794227
Hey Eric - we'd have to see your code.  Typically, having duplicate sortOrder would not prevent something from showing.  The only negative effect would be that you can't predict the order of the two items with the same sortOrder.. you can always handle that with a 2nd sort column such as "title" or "name"

I recall that you were grouping by the sort order.. perhaps that's what you mean?   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..
0
 
LVL 3

Author Comment

by:Eric Bourland
ID: 37798106
I think I resolved this.

>>>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:

<!--- get table columns for parent, child, grandchild records--->
<cfquery name="getPages" datasource="#APPLICATION.dataSource#">
SELECT
       p.PageID     AS PageIDLevel1
      ,p.PageTitle  AS PageTitleLevel1
      ,p.SortOrder  AS SortOrderLevel1
      ,p.ParentID   AS ParentIDLevel1
      ,c.PageID     AS PageIDLevel2
      ,c.PageTitle  AS PageTitleLevel2
      ,c.SortOrder  AS SortOrderLevel2
      ,c.parentID   AS ParentIDLevel2
      ,gc.PageID    AS PageIDLevel3
      ,gc.PageTitle AS PageTitleLevel3
      ,gc.SortOrder AS SortOrderLevel3
      ,gc.parentID  AS ParentIDLevel3
      ,p.DateCreated AS DateCreatedLevel1
      ,p.DateModified AS DateModifiedLevel1
      ,c.DateCreated AS DateCreatedLevel2
      ,c.DateModified AS DateModifiedLevel2
      ,gc.DateCreated AS DateCreatedLevel3
      ,gc.DateModified AS DateModifiedLevel3
     
FROM #REQUEST.contentTable# p
                  LEFT JOIN #REQUEST.contentTable#  c ON c.parentID = p.pageID
                  LEFT JOIN #REQUEST.contentTable#  gc ON gc.parentID = c.PageID
WHERE   ISNULL(p.parentID, 0) = 0
ORDER BY p.SortOrder, c.SortOrder, gc.SortOrder
</cfquery>

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
0
 
LVL 3

Author Closing Comment

by:Eric Bourland
ID: 37799250
>>>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
0

Featured Post

Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Show "Processing please wait" while CFGRID getting ready to load 23 126
Airline check in kiosk 4 112
REGEX HELP 11 48
BACKUP of mysql database from mysql server - using Coldfusion 9 42
Hi, I will be creating today a basic tutorial on how we can create a Mail Custom Function and use it where ever we want. The main advantage about creating a custom function is that we can accommodate a range of arguments to pass to the Function and …
PROBLEM:  How to open a cfwindow or run a function on double click of a cfgrid row. One of my clients wanted to be able to double click on a row item to get more detailed information about a transaction and to be able to modify the line items i…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

860 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question