<ul>
<li><a href="index.cfm?home">Home</a></li>
<li><a href="index.cfm?signup">Signup</a></li>
<li><a href="index.cfm?login">Login</a></li>
<li><a href="index.cfm?about">About</a></li>
</ul>
Step 3: add Coldfusion code into #main section
With Coldfusion we will use URL variables, <cfif> and <cfinclude> tags. Remember a Coldfusion URL variable is defined simply with this dotted code URL + . + 'varname' (URL.varname). Copy and paste this code into the #main section of our index.cfm page:
<div id="main">
<!-- If is defined an URL variable with value signup, logi or about: -->
<cfif isDefined('URL.signup')>
<cfinclude template="include/in-signup.cfm">
<cfelseif isDefined('URL.login')>
<cfinclude template="include/in-login.cfm">
<cfelseif isDefined('URL.about')>
<cfinclude template="include/in-about.cfm">
<cfelse>
<!-- else, in all other cases load home page -->
<cfinclude template="include/in-home.cfm">
</div>
<!-- If is defined an URL variable with value signup, logi or about: -->
<cfif isDefined('URL.signup')>
<cfinclude template="include/in-signup.cfm">
<cfelseif isDefined('URL.login')>
<cfinclude template="include/in-login.cfm">
<cfelseif isDefined('URL.about')>
<cfinclude template="include/in-about.cfm">
<cfelse>
<!-- else, in all other cases load home page -->
<cfinclude template="include/in-home.cfm">
</div>
How you can see the code is very similar to the code used with PHP in this post, and the conceptual structure is exactly the same.
No comments:
Post a Comment