Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

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

Posted on 2010-11-22
13
Medium Priority
?
381 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 53

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 53

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
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
LVL 53

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 53

Accepted Solution

by:
_agx_ earned 2000 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 53

Assisted Solution

by:_agx_
_agx_ earned 2000 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 53

Expert Comment

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

Cool. I need it today :)
0
 
LVL 53

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 53

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: 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.

Question has a verified solution.

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

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 …
I spent nearly three days trying to figure out how incorporate OAuth in Coldfusion for the Eventful API. Hopefully, this article will allow Coldfusion Programmers to buzz through the API when they need to. Basically, what this script does is authori…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
The Relationships Diagram is a good way to get an overall view of what a database is keeping track of. It is also where relationships are defined. A relationship specifies how two tables connect to each other. As you build tables in Microsoft Ac…
Suggested Courses

571 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