Solved

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

Posted on 2010-11-22
13
373 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
  • 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
Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

 
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
Hi. There are several upload tutorials using jquery and coldfusion. I found a very interesting one here Upload Your Files using Jquery & ColdFusion and Preview them (http://www.randhawaworld.com/) . I did keep the main js functions but made sever…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

749 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