150 likes | 174 Views
Learn how to utilize URL variables in ColdFusion to create dynamic site layout and navigation. Explore concepts like CFINCLUDE, CFSWITCH, CFIF, and CFTRY for error handling. Utilize URL variables like "VIEW" and "PAGE" to customize content areas. Understand the importance of application.cfm files for dynamic page building. Attend MDCFUG meetings for more insights. Contact Jon Brundage for ColdFusion development and Section 508 accessibility consulting.
E N D
Page Layout and Navigation in ColdFusion Jon Brundage CF Developer / Accessibility and Section 508 Consultant jonwind@windcompany MDCFUG April 2003
CF is power in your hands • This discussion shows how to use URL variables to create sophisticated layout and navigation. • You are only limited by your imagination.
CFINCLUDE CFSWITCH CFIF CFTRY (for error handling) Tags we will be using
Basic Concepts Adding URL variables to links exposes the variables for use by site pages. We will create and use URL variables “VIEW” and “PAGE” example: <A href=“index.cfm?view=home”>
Some special files • config.cfm • nav files
Pages are created by components • header • left navigation (CFINCLUDE template=“leftNav.cfm”) • content area depends on URL variable (CFINCLUDE template=“#view#.cfm”) • footer
how it works • variables are set to default values when site is entered • as links are selected URL variables are passed for use by config.cfm, leftNav.cfm and index.cfm • pages are built based on the exposed URL variable
Page layout index.cfm HEADER leftNav (<cfinclude template= “leftNav.cfm”>) content area (<cfinclude template=“#view#.cfm”>) FOOTER
config.cfm • included at top of index.cfm • sets variables such as #title#, #describe#, #breadcrumb# • uses <CFSWITCH> to set variable values depending on URL
leftNav.cfm • creates a navigation system • all links have URL variables added to HREF <a href=“index.cfm?view=home”> • leftNav uses <CFIF> to control appearance
other uses • add additional URL variables for subfolder content “page=travel” • use URL variable in queries
error handling • use CFTRY to prevent URL “hacking” or misspelling of URL • <cftry> • <cfinclude template=“#view#.cfm”> • <cfcatch type="MissingInclude"> • <cfset view="home"> • <cfinclude template="#view#.cfm"> • </cfcatch> • </cftry>
caution using application.cfm files A reminder- using this system results in the building of index.cfm in a dynamic fashion. Your pages are processed from the root folder where index.cfm resides. Even if content is drawn from sub-folders only the application.cfm file in the root folder is processed. Any application.cfm in sub-folders ignored.
thanks! • Have fun and be creative! • MDCFUG a great asset-attend these meetings, get on the mailing list, visit their site (http://www.teratech.com/) and sign up for classes.
Jon Brundage • Section 508 / web accessibility consulting • ColdFusion development • jonwind@windcompany.com • 703-967-1024