How can I get both of these custom links to work in my parent-child navigation menu?

Hi. I have a navigation menu that displays parent and child navigation menu items in a dropdown menu. It works very well. The navigation items are kept in a data table, and are ordered by a value in column SortOrder.

Now, the client wants to manually edit some of the child navigation menu items. So, I add a CFIF statement: if PageID IS 19, then omit the PageID and replace it with a custom link: like this:
 
         <ul>  
        <cfloop query="fetchChildren">
       
         <cfif fetchChildren.PageID IS NOT 19>

        <li><a href="/index.cfm?PageID=#fetchChildren.PageID#">#fetchChildren.pageTitle#</a></li>
           
         <cfelseif fetchChildren.PageID IS 19>
         <li><a href="javascript:launchWS('http://clients.mindbodyonline.com/ws.asp?studioid=9717&stype=-7&sTG=22&sView=week');">#fetchChildren.pageTitle#</a></li>
         
    </cfif>

        </cfloop>  
        </ul>
 
 And that works fine.
 
 Question: now the client wants me to also replace PageID 29 with a custom link, much as above. But, when I add this:
         <ul>  
        <cfloop query="fetchChildren">
       
         <cfif fetchChildren.PageID IS NOT 19>

        <li><a href="/index.cfm?PageID=#fetchChildren.PageID#">#fetchChildren.pageTitle#</a></li>
           
         <cfelseif fetchChildren.PageID IS 19>
         <li><a href="javascript:launchWS('http://clients.mindbodyonline.com/ws.asp?studioid=9717&stype=-7&sTG=22&sView=week');">#fetchChildren.pageTitle#</a></li>

         <cfif fetchChildren.PageID IS NOT 29>

        <li><a href="/index.cfm?PageID=#fetchChildren.PageID#">#fetchChildren.pageTitle#</a></li>


         <cfelseif fetchChildren.PageID IS 29>
         <li><a href="javascript:launchWS('http://clients.mindbodyonline.com/ws.asp?studioid=9717&stype=-8&sTG=23&sVT=15&sView=week');">#fetchChildren.pageTitle#</a></li>


    </cfif>

        </cfloop>  
        </ul>

That obviously does not work. How can I get both of these custom links to work in my parent-child navigation menu? If PageID = 19, point the menu item to here. If PageID = 29, point that menu item to there.

Is that possible?

Have I explained this well?

Thanks as always.

Eric
LVL 3
Eric BourlandAsked:
Who is Participating?
 
_agx_Connect With a Mentor Commented:
Yeah, I understand you want to generate different links for pageID's 19 and 29. What I don't understand is why the basic logic wouldn't work.  If it works for 19, then it should work the same way for 29 too. Does that make sense?

<cfif fetchChildren.PageID IS 19>
    do X
<cfelseif fetchChildren.PageID IS 29>
    do Y
<cfelse>
    generate normal links ...
</cfif>
0
 
_agx_Commented:
Hi Eric,

Are you saying there are three cases?
- If the pageID = 19, then do X
- If the pageID = 29, then do Y
- Otherwise,  do Z

If so, wouldn't it just be a  CFIF / CFELSEIF / CFELSE :)
0
 
_agx_Commented:

ie
<cfif fetchChildren.PageID IS 19>
    do X
<cfelseif fetchChildren.PageID IS 29>
    do Y
<cfelse>
    do Z
</cfif>
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
Eric BourlandAuthor Commented:
>>>If so, wouldn't it just be a  CFIF / CFELSEIF / CFELSE :)

I'll try to explain. I think I do need a CFIF statement, because this is what needs to happen:

IF PageID = 19 is selected from the navigation menu, THEN do not show that navigation menu item; that is, do not go to PageID=19; instead, go to this link:

<a href="javascript:launchWS('http://clients.mindbodyonline.com/ws.asp?studioid=9717&stype=-7&sTG=22&sView=week');">#fetchChildren.pageTitle#</a>

I explained my steps in the code below; I commented a little better. You can see it working here:

http://www.buddhabyoga.com/

I mean, at that URL, the child link for PageID = 19 does NOT link to PageID=19, but instead links to a popup window for a Yoga class registration page.

So, I need both X and Y to happen:

<cfif fetchChildren.PageID IS 19>
    do X
<cfelseif fetchChildren.PageID IS 29>
    do Y

but I also need to make sure that the link to X is not PageID=19, and the link to Y is not PageID=29; and that all of the other Parent - Child links display.

I hope this remotely makes sense. =)

Eric
<ul>  
        <cfloop query="fetchChildren">
        
     <!--- FETCH all children that are NOT PageID=19 --->
        
         <cfif fetchChildren.PageID IS NOT 19>

        <li><a href="/index.cfm?PageID=#fetchChildren.PageID#">#fetchChildren.pageTitle#</a></li>

  <!--- why do we FETCH all children that are NOT PageID=19? --->
  
    <!--- because we do not want the link to PageID=19 to display in navigation! --->
       
              
 <!--- instead, we want this link to PageID=19 to display --->            
         <cfelseif fetchChildren.PageID IS 19>
         <li><a href="javascript:launchWS('http://clients.mindbodyonline.com/ws.asp?studioid=9717&stype=-7&sTG=22&sView=week');">#fetchChildren.pageTitle#</a></li>
         
   
 <!--- I am also trying to get this link to PageID=29 to display --->   
         <cfelseif fetchChildren.PageID IS 29>
         <li><a href="javascript:launchWS('http://clients.mindbodyonline.com/ws.asp?studioid=9717&stype=-8&sTG=23&sVT=15&sView=week');">#fetchChildren.pageTitle#</a></li>

    </cfif>
 
       
        </cfloop>  
        </ul>

Open in new window

0
 
_agx_Commented:
I think I do need a CFIF statement,

Hmm... I'm not sure how that's not handled by 3 conditions.  But ..

but I also need to make sure that the link to X is not PageID=19, and the link to Y is not PageID=29

Sorry, I don't understand that part at all :)  
0
 
Eric BourlandAuthor Commented:
I'm sorry to be confusing. I will try to explain.

This code fetches all child navigation items:

   <ul>  
        <cfloop query="fetchChildren">

        <li><a href="/index.cfm?PageID=#fetchChildren.PageID#">#fetchChildren.pageTitle#</a></li>
       
       </cfloop>  
  </ul>

That works very well. There are 29 PageIDs in all; each PageID is either a Parent ID or a Child ID. These Parent and Child IDs populate the navigation menu item dynamically. Its works like a charm.

But, the client is not happy with that. =)

One of the child menu items is http://www.buddhabyoga.com/index.cfm?PageID=19. So, selecting http://www.buddhabyoga.com/index.cfm?PageID=19 in the navigation menu should lead us to this URL:

http://www.buddhabyoga.com/index.cfm?PageID=19

The client does not want that. What she wants to happen is, when someone clicks on http://www.buddhabyoga.com/index.cfm?PageID=19, she gets sent to a href="javascript:launchWS('http://clients.mindbodyonline.com/ws.asp?studioid=9717&stype=-7&sTG=22&sView=week');" instead.

Thus, the CFIF statement above.

I used this to omit the "real" link to http://www.buddhabyoga.com/index.cfm?PageID=19 created by query="fetchChildren":

 <cfif fetchChildren.PageID IS NOT 19>  

Then I replace the link to http://www.buddhabyoga.com/index.cfm?PageID=19 with this:

<cfelseif fetchChildren.PageID IS 19>  
         <li><a href="javascript:launchWS('http://clients.mindbodyonline.com/ws.asp?studioid=9717&stype=-7&sTG=22&sView=week');">#fetchChildren.pageTitle#</a></li>

And this works OK:

http://www.buddhabyoga.com/

If you look at that page, and click on Classes | Class and Workshop Schedules, you will find you link not to http://www.buddhabyoga.com/index.cfm?PageID=19, but to <a href="javascript:launchWS('http://clients.mindbodyonline.com/ws.asp?studioid=9717&stype=-7&sTG=22&sView=week');">#fetchChildren.pageTitle#</a>.

So, essentially, I edited the output of query="fetchChildren". When query="fetchChildren" fetches PageID = 19, the associated link is not http://www.buddhabyoga.com/index.cfm?PageID=19, but  <a href="javascript:launchWS('http://clients.mindbodyonline.com/ws.asp?studioid=9717&stype=-7&sTG=22&sView=week');">#fetchChildren.pageTitle#</a>.
0
 
_agx_Connect With a Mentor Commented:
If you test the basic logic it seems to work as you described.  Granted my statements are in a different order. But the basic logic holds.  I don't see why your results would be different

<!--- generate a sample query --->
<cfset fetchChildren = queryNew("")>
<cfset queryAddColumn(fetchChildren, "PageID", listToArray("1,5,19,20,29,30"))>

<cfoutput>       
   <cfloop query="fetchChildren">
      <cfif fetchChildren.PageID IS 19>
          pageID = #pageID# :: do X  
      <cfelseif fetchChildren.PageID IS 29>
          pageID = #pageID# :: do Y
      <cfelse>
          pageID = #pageID#:: generate normal links ...
      </cfif>
      <br />
   </cfloop>  
</cfoutput>

results:
pageID = 1:: generate normal links ...
pageID = 5:: generate normal links ...
pageID = 19 :: do X
pageID = 20:: generate normal links ...
pageID = 29 :: do Y
pageID = 30:: generate normal links ...
0
 
Eric BourlandAuthor Commented:
Um. Well. That worked. I was doing it backwards. And introduced complexity.

Learn something new every day.

~sheepish~

http://www.buddhabyoga.com/

You've earned a great deal of yogic karma today.
<ul>  
        <cfloop query="fetchChildren">
        
     <!--- FETCH all children that are NOT PageID=19 --->
        
         <cfif fetchChildren.PageID IS 19>
         
 <li><a href="javascript:launchWS('http://clients.mindbodyonline.com/ws.asp?studioid=9717&stype=-7&sTG=22&sView=week');">#fetchChildren.pageTitle#</a></li>
 
 
 <cfelseif fetchChildren.PageID IS 29>
         <li><a href="javascript:launchWS('http://clients.mindbodyonline.com/ws.asp?studioid=9717&stype=-8&sTG=23&sVT=15&sView=week');">#fetchChildren.pageTitle#</a></li>
 
 <cfelse>
        <li><a href="/index.cfm?PageID=#fetchChildren.PageID#">#fetchChildren.pageTitle#</a></li>

    </cfif>
 
        </cfloop>  
        </ul>

Open in new window

0
 
Eric BourlandAuthor Commented:
I learned a better way to set up that CFIF statement. It is a lesson I will keep and apply later. Thanks as always to _agx_.
0
 
_agx_Commented:
>> You've earned a great deal of yogic karma today

Cool. I need it today :)
0
 
_agx_Commented:
>> What I don't understand is why the basic logic wouldn't work.

Silly me. The first CFIF matches the value 29 too. So the code never even reached the last condition:

<cfif fetchChildren.PageID IS NOT 19> <!--- will match pageID=29 --->
<cfelseif fetchChildren.PageID IS 19>
<cfelseif fetchChildren.PageID IS 29>
</cfif>
0
 
Eric BourlandAuthor Commented:
>>>The first CFIF matches the value 29 too. So the code never even reached the last condition:

<cfif fetchChildren.PageID IS NOT 19> <!--- will match pageID=29 --->


I eventually figured this out too =)
0
 
_agx_Commented:
I should have seen it sooner.  I was too focused on my example and missed it. Bad brain! ;-)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.