Skip to main content
Known Participant
August 11, 2008
Answered

Output issue while grouping

  • August 11, 2008
  • 17 replies
  • 2539 views
OK guys... I have written a dynamic hierarchial menu that uses CSS. My issue is that I have 6 main menu items and each item has submenus. I have it ready to go in theory, but my cfoutput keeps repopulating the first entry.


I am hoping someone can help ASAP. I have 6 of the same thing.

JG
    This topic has been closed for replies.
    Correct answer -__cfSearching__-
    jgethers wrote:
    > It works well, except it doesnt output 2 3 4 5 6.

    It never retrieves them in the first place. That is the problem, not the output.

    Are there actually pagecontent records for parentID values 2, 3, 4, 5 and/or 6? If not, those those menu items will not appear in the results because you are using an INNER JOIN.

    Try changing the INNER JOIN to a LEFT JOIN. That will include all records from the left hand table (ie cssmenu) even if there are no matching records in pagecontent .

    If that does not help, run a select on both tables separately and cfdump the results of the two queries.

    17 replies

    jgethersAuthor
    Known Participant
    August 12, 2008
    SWEET! It works. Now I just have to get the CSS to work right in Firefox.

    Thanks Man!
    jgethersAuthor
    Known Participant
    August 12, 2008
    ok I will try that.
    Inspiring
    August 12, 2008
    If an mID has no matching child records then the pName will be null. You can use cfif to generate the <div></div> tags, and links, only when the child value is not emtpy string.

    jgethersAuthor
    Known Participant
    August 12, 2008
    yes they are used to match the subs o the mains
    jgethersAuthor
    Known Participant
    August 12, 2008
    Nice. I had data in there, but when I changed the structure, I cleaned it up. Sorry man. 1 more question. How can I kill the output if it doesnt have a child object so I do not have empty menus?
    jgethersAuthor
    Known Participant
    August 12, 2008
    ok left join outputs the 6 buttons but still only 1 child. It gives each menu a blank field.
    Inspiring
    August 12, 2008
    -==cfSearching==- wrote:
    > If that does not help, run a select on both tables separately
    > and cfdump the results of the two queries.

    ie

    <cfquery name="debugMenu" datasource="#DSN#">
    SELECT *
    FROM cssmenu
    </cfquery>
    <cfquery name="debugPageContent" datasource="#DSN#">
    SELECT *
    FROM pagecontent
    </cfquery>

    <cfdump var="#debugMenu#">
    <cfdump var="#debugPageContent#">
    Inspiring
    August 12, 2008
    > MID PARENTID PLINK PNAME
    > 7 2 [empty string] [empty string] [empty string]
    > 8 3 [empty string] [empty string] [empty string]
    > 9 4 [empty string] [empty string] [empty string]
    > 10 5 [empty string] [empty string] [empty string]
    > 11 6 [empty string] [empty string] [empty string]

    Yes, the problem is there are no matching pagecontent records for mID's 2, 3, ...6. Dump the pagecontent table. Are there just no records for those parentID's, are the parentID's wrong, etcetera... ?

    BTW, should the SELECT really be returning the menu ID twice: mID and parentID column?
    -__cfSearching__-Correct answer
    Inspiring
    August 12, 2008
    jgethers wrote:
    > It works well, except it doesnt output 2 3 4 5 6.

    It never retrieves them in the first place. That is the problem, not the output.

    Are there actually pagecontent records for parentID values 2, 3, 4, 5 and/or 6? If not, those those menu items will not appear in the results because you are using an INNER JOIN.

    Try changing the INNER JOIN to a LEFT JOIN. That will include all records from the left hand table (ie cssmenu) even if there are no matching records in pagecontent .

    If that does not help, run a select on both tables separately and cfdump the results of the two queries.
    jgethersAuthor
    Known Participant
    August 12, 2008
    Well all of those Parent IDs are correct and they all are child objects of mID1. It works well, except it doesnt output 2 3 4 5 6.
    jgethersAuthor
    Known Participant
    August 11, 2008
    I know this may sound funny, but can I cfloop the output to do what I want?
    Inspiring
    August 11, 2008
    jgethers wrote:
    > I know this may sound funny, but can I cfloop the output to do what I want?

    First figure out what is wrong with your query.

    Look at the output. All of the mID and parentID values equal 1. I doubt that is correct, but given those results the cfoutput code is behaving correctly. It only produces 1 menu item because you are grouping by mID and there is only one mID value in the results. Either the data values in your tables are incorrect or your join/select statement is incorrect...