Solved

question: using CFIF to modify Parent navigation menu

Posted on 2011-02-14
3
459 Views
Last Modified: 2012-05-11
Hi. I am trying to modify a navigation menu. This nav menu displays links to parent and children pages. I want to change the links of two of the parent pages: PageID=11 and PageID=12.

* I need the link to PageID=11 to point to http://www.buddhabyoga.com/blog/, not to http://www.buddhabyoga.com/index.cfm?PageID=11.

* And I need the link to PageID=12 to point to javascript:launchWS('http://clients.mindbodyonline.com/ws.asp?studioid=9717&stype=43');, not to http://www.buddhabyoga.com/index.cfm?PageID=12.

The current query and HTML, below, almost work. But right now, parent menu items Blog and Boutique appear twice. My client is a little impatient. =) How can I get rid of the extra parent navigation menu links?

Thanks for your advice as always. Eric B

Queries:

<cfparam name="url.PageID" default="1" />

<!--- this query will retrieve all records --->  
<cfquery datasource="#ds#" name="qry_GetPages">  
SELECT PageID, PageTitle, buddha_main, two_col_interior_left, two_col_interior_right, two_col_content_lower_page, right_col_menu_item, ParentID, SortOrder
FROM  tbl_buddhab_navigation  
</cfquery>  
  
<!--- this will retrieve just the parent records from the previous query --->  
<cfquery name="fetchTopNav" dbtype="query">  
SELECT *  
FROM qry_GetPages  
WHERE ParentID = <cfqueryparam cfsqltype="cf_sql_integer" value="0" maxlength="2">
ORDER BY SortOrder  
</cfquery> 


HTML:

<div class="menu">

<ul>  
<cfoutput query="fetchTopNav">  

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

<cfif fetchTopNav.pageID IS 12>
	<li><a href="javascript:launchWS('http://clients.mindbodyonline.com/ws.asp?studioid=9717&stype=43');">#fetchTopNav.pageTitle#</a>
</cfif>

<cfif fetchTopNav.pageID IS 11>       
	<li><a href="/blog/">Blog</a>
</cfif>
         
  
  <cfquery name="fetchChildren" dbtype="query">  
    SELECT *   
    FROM qry_GetPages  
    WHERE parentID = <cfqueryparam value="#val(fetchTopNav.pageid)#" cfsqltype="cf_sql_integer">
    ORDER BY sortorder asc  
  </cfquery>  
  
  <cfif fetchChildren.recordCount gt 0>  


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

        
       
                
  </cfif>  
  </li>  
</cfoutput>  
</ul> 
</div>

Open in new window

0
Comment
Question by:Eric Bourland
  • 2
3 Comments
 
LVL 52

Accepted Solution

by:
_agx_ earned 500 total points
ID: 34890838
Try making the conditions mutually exclusive


ie instead of:
   <li> ... default link....
   <cfif fetchTopNav.pageID IS 12> .... custom link </cfif>
   <cfif fetchTopNav.pageID IS 11> .... custom link </cfif>      

use
   <cfif fetchTopNav.pageID IS 12> 
           .... custom link
   <cfelseif fetchTopNav.pageID IS 11> 
           .... custom link 
   <cfelse>
         <li> ... default link....
   </cfif>      

Open in new window

0
 
LVL 3

Author Closing Comment

by:Eric Bourland
ID: 34890937
This worked like a charm. =) And I see what I was missing. Thank you _agx_.

Sweet. Client is happy.

Eric B
0
 
LVL 3

Author Comment

by:Eric Bourland
ID: 34899671
I applied the same procedure to another web site to resolve a problem with navigation menu formatting. Thank you again. =) Hope your day is going well. EB
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Airline check in kiosk 4 99
Need to use URL Encode in CFDiv Tag ColdFusion, receiving error 2 56
Sending Text Messages 1 52
Weird Behavior in ColdFusion 8 71
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…
Sometimes databases have MILLIONS of records and we need a way to quickly query that table to return the results me need. Sure you could use CFQUERY but it takes too long when there are millions of records. That is why SOLR was invented. Please …
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

910 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

21 Experts available now in Live!

Get 1:1 Help Now