Copy link to clipboard
Copied
I have a website where the navigation bar appears on every page. This is so I can edit the navbar in one location and it will change in each subsequent page automatically. However I want to have the option to display the navbar or not display it based on the type of page that it is.
I achieved the navbar being displayed on each page via my application.cfc under the “request start“ tag. Is there a way that I can selectively omit my navigation bar depending on the page that I select?
Any suggestions on the direction? I should go with my coding
<cffunction name="onRequestStart" returnType="boolean" output="true"> <!--- Any variables set here can be used by all our pages --->
<!---02/20/2023--->
<cfinclude template="navbar_admin.cfm">
<cfset request.companyName = "BK_Club">
Copy link to clipboard
Copied
Depending on the complexity of your nave bar, an option is to hide it via client side using JS/Jquery/css that is controled on the page. Our nav bar is really simple so hidding it is not that a big deal.
Copy link to clipboard
Copied
I am assuming that the list of CFM pages you wish to omit is fixed throughout the duration of the application. Then I can think of an easy solution. In ColdFusion.
<!--- In Application.cfc's onApplicationStart() --->
<!--- Define array of CFM pages for which to omit the navbar --->
<cfset application.arrayOfPagesToOmitNavbar=["page123.cfm","page987.cfm","page456.cfm"]>
<!--- In onRequestStart() --->
<!--- Check if current CFM page is in array of pages for which to omit the navbar --->
<cfset var currentPage = listLast(arguments.targetPage, "/\")>
<cfset var currentPageOmitsNavbar = application.arrayOfPagesToOmitNavbar.containsNoCase(currentPage)>
<!--- Check if current page allows navbar --->
<cfif not currentPageOmitsNavbar>
<cfinclude template="navbar_admin.cfm">
</cfif>
Copy link to clipboard
Copied
Hi @HumbleCF ,
Did our suggestions help?