- Back to Home »
- coldfusion , html »
- Load pages using URL variables with Coldfusion cfinclude and cfif tag
Posted by : gadget bloggers
Selasa, 09 Oktober 2007
The same approach used in all previous post can be used with other server-side languages, for example Coldfusion. This post show how to load pages using Coldfusion URL variables with <cfinclude> and <cfif> tag.
A coldfusion URL Variable is defined simply with this dotted code (URL + . + 'varname'):
URL.varname
Copy and paste this code inside the #main section in index.cfm file (see this post to examine the page structure):
<!-- If is defined URL variable 'aboutme' -->
<cfif isDefined('URL.aboutme')>
<!-- include page 'about me' -->
<cfinclude template="include/in-aboutme.cfm">
<!-- else if is defined URL variable 'interests' -->
<cfelseif isDefiend('URL.interests')>
<!-- include page 'interests' -->
<cfinclude template="include/in-interests.cfm">
<cfelse>
<!-- in all other cases include the home page -->
<cfinclude template="include/in-home.cfm">
</cfif>
<cfif isDefined('URL.aboutme')>
<!-- include page 'about me' -->
<cfinclude template="include/in-aboutme.cfm">
<!-- else if is defined URL variable 'interests' -->
<cfelseif isDefiend('URL.interests')>
<!-- include page 'interests' -->
<cfinclude template="include/in-interests.cfm">
<cfelse>
<!-- in all other cases include the home page -->
<cfinclude template="include/in-home.cfm">
</cfif>
The result is the same obtained with PHP in the previous post.