• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Display a navbar or hide it by page

Community Beginner ,
Mar 23, 2023 Mar 23, 2023

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

 

Views

194

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 24, 2023 Mar 24, 2023

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 25, 2023 Apr 25, 2023

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>

 

 

 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 15, 2023 May 15, 2023

Copy link to clipboard

Copied

LATEST

Hi @HumbleCF ,

Did our suggestions help?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation