Often times, you'll use some of the same elements in multiple pages; for example, navigation, headers, and footer code.
Instead of copying and maintaining it from page to page, ColdFusion allows you to reference the code stored in one file in many pages. This way you can modify one file and recognize the changes throughout an entire application.
Use the CFINCLUDE tag to automatically include an existing file in the current page.
|Note:||Refer to the CFML Language Reference for ColdFusion Express for CFINCLUDE syntax.|
In this example, the navigation toolbar is included (not copied) at the top of the calling page,
Toolbar.cfmis included for processing.
Toolbar.cfmresides in the same directory as
Toolbar.cfmresided in the Templates directory underneath the calling page's directory, the syntax would be:
During the next procedure, use CFINCLUDE on your
FormAction.cfm pages to reuse the application's navigation code.
|To reference code in a calling page:|
<!--- begin application toolbar imported from toolbar.cfm--->
And ends with this:<!--- end application toolbar --->
Toolbar.cfmfile in this page:
EmpList.cfmin a browser.
You will modify this form during the next chapter's procedures to create a search form.
EmpList.cfmin a browser and navigate to
SearchForm.cfmby clicking SEARCH.
The toolbar should now be included.
Click here to see what the
Emplist.cfm looks like.
Click here to see what
SearchForm.cfm looks like.
Click here to see the search form's code.
In the next chapter, you will code the form so that it really does search the database.
Move on in this chapter to review development considerations.