Solved

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

Posted on 2010-11-22
13
365 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_
Comment Utility
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_
Comment Utility

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
Comment Utility
>>>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
 
LVL 52

Expert Comment

by:_agx_
Comment Utility
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
Comment Utility
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
Comment Utility
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
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 52

Assisted Solution

by:_agx_
_agx_ earned 500 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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_
Comment Utility
>> You've earned a great deal of yogic karma today

Cool. I need it today :)
0
 
LVL 52

Expert Comment

by:_agx_
Comment Utility
>> 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
Comment Utility
>>>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_
Comment Utility
I should have seen it sooner.  I was too focused on my example and missed it. Bad brain! ;-)
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

This is an updated version of a post made on my blog over 3 years ago. It is unfortunately, still very relevant as we continue to see both SQLi (SQL injection) and XSS (cross site scripting) attacks hitting some of the most recognizable website and …
CFGRID Custom Functionality Series -  Part 1 Hi Guys, I was once asked how it is possible to to add a hyperlink in the cfgrid and open the window to show the data. Now this is quite simple, I have to use the EXT JS library for this and I achiev…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

743 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now