Skip to main content
Inspiring
April 23, 2008
Question

Best way to accoplish adding navigation based on security rights (cfinclude)

  • April 23, 2008
  • 2 replies
  • 415 views
I need to figure out the best way display a navigation template based on login rights.
I have created 4 navigation templates (1 for no login, 3 for different security right logins).
What I have tried doesn't work correctly. (Everything works until the last cfif Not IsDefine. If session.mm_userauthorization is blank then no naviagion template appears at all on the page. If I veiw the session variables in debugging it shows mm_userauthorization= ) Once a user logs in the template updates correctly based on login rights.
What is the best way to accomplish this? Thanks!

<cfif IsDefined('Session.mm_userauthorization') AND ListFindNoCase(1,Session.mm_userauthorization)gt 0>
<cfinclude template="side_buttonsOLDp.cfm">
<cfif IsDefined('Session.mm_userauthorization') AND ListFindNoCase(2,Session.mm_userauthorization)gt 0>
<cfinclude template="side_buttonsOLDf.cfm">
<cfif IsDefined('Session.mm_userauthorization') AND ListFindNoCase(3,Session.mm_userauthorization)gt 0>
<cfinclude template="side_buttonsOLDb.cfm">
<cfif NOT ISDefined('Session.mm_userauthorization') >
<cfinclude template="side_buttonsOLD.cfm">
</cfif></cfif></cfif></cfif>
    This topic has been closed for replies.

    2 replies

    Inspiring
    April 23, 2008
    You could use CFSWITCH / CFCASE to determine what template to load when there is a login, and use the DEFAULTCASE setting to load the "no login" template.

    This would also allow easier adding of templates if you decide to add more login types in the future
    sic4730Author
    Inspiring
    April 24, 2008
    Thank you!
    I will read up on cfcase/cfswitch.
    Inspiring
    April 23, 2008
    A blank session variable still exists so isDefined will return true.