Solved

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

Posted on 2010-11-22
13
375 Views
Last Modified: 2012-05-10
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
0
Comment
Question by:Eric Bourland
[X]
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
  • 8
  • 5
13 Comments
 
LVL 52

Expert Comment

by:_agx_
ID: 34190664
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
 
LVL 52

Expert Comment

by:_agx_
ID: 34190677

ie
<cfif fetchChildren.PageID IS 19>
    do X
<cfelseif fetchChildren.PageID IS 29>
    do Y
<cfelse>
    do Z
</cfif>
0
 
LVL 3

Author Comment

by:Eric Bourland
ID: 34191597
>>>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
Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.

 
LVL 52

Expert Comment

by:_agx_
ID: 34191777
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
 
LVL 3

Author Comment

by:Eric Bourland
ID: 34192035
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
 
LVL 52

Accepted Solution

by:
_agx_ earned 500 total points
ID: 34192145
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
 
LVL 52

Assisted Solution

by:_agx_
_agx_ earned 500 total points
ID: 34192207
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
 
LVL 3

Author Comment

by:Eric Bourland
ID: 34192409
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
 
LVL 3

Author Closing Comment

by:Eric Bourland
ID: 34192419
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
 
LVL 52

Expert Comment

by:_agx_
ID: 34192544
>> You've earned a great deal of yogic karma today

Cool. I need it today :)
0
 
LVL 52

Expert Comment

by:_agx_
ID: 34192590
>> 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
 
LVL 3

Author Comment

by:Eric Bourland
ID: 34192596
>>>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
 
LVL 52

Expert Comment

by:_agx_
ID: 34192628
I should have seen it sooner.  I was too focused on my example and missed it. Bad brain! ;-)
0

Featured Post

Containers and Docker for Everyone

Containers are an incredibly powerful technology that can provide you and/or your engineering team with huge productivity gains. Using containers, you can deploy, back up, replicate, and move apps and their dependencies quickly and easily.

Question has a verified solution.

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

This article  is about submitting  form through  ColdFusion.Ajax.submitForm to the action page and send a response back in JSON format which later can be decoded using ColdFusion.JSON.decode. By this way you can avoid the usual page refresh for subm…
The technique is by far very Simple! How we can export the ColdFusion query results to DOC file?  Well before writing this I researched a lot in Internet but did not found a good Answer anyways!  So i thought now i should share my small snippet w…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…

707 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