ColdFusion Tutorial
Using cfinclude helps reusing and maintain text or code.
|
The <cfinclude> tag include a template into your page. Using <cfinclude> helps reusing and maintain text or code. When using cfinclude you can have a nice header and footer on every page. Because you don?t have to type the code in it again and again, you can be sure that the consistency of your pages won?t suffer from the extra code. Syntax:
As an example, lets say that every page should have the same text at end of each page. First make a template, let's call it bottom.cfm. <div align="center"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Copyright Site Name - All Rights Reserved.</font>
?. Every page that you have included the bottom template on, will have the text you entered in the bottom template. Changing the text or add an image in the bottom template, will automatically being updated on those pages. So by using the <cfinclude> tage you only have to change the code in the included template to have the changes updated on all your pages. See this tutorial for an example. Notice: be careful using the html tags below in your templates, so you don't duplicate those tags on your pages. <html> <head> <title>..</title> </head> <body> </body> </html> |
|
Page layout and cfinclude. | ||||||
| So far we are using cfinclude on a page without tables. Let?s imagine that your site layout is something like this: | ||||||
|
||||||
| Ok, let?s make five templates: | ||||||
| One for the main page that is the site layout, we can call this main_page.cfm. | ||||||
| The rest of our templates we include in the main_page.cfm. | ||||||
| Page top template [page_top.cfm] | ||||||
| ||||||
| Navigation menu template [navigation_menu.cfm] | ||||||
| ||||||
| Page contains template [page_contains.cfm] | ||||||
| ||||||
| Page bottom template [page_bottom.cfm] | ||||||
| ||||||
| Main Page template [main_page.cfm] | ||||||
| ||||||
| The index.cfm file [that starts everything] | ||||||
| ||||||
| Now, run the index.cfm file and if everything is correct you will get the following output in your browser. | ||||||
| ||||||
ColdFusion Tutorial test
Using cfinclude helps reusing and maintain text or code.
No test is available or implemented for this ColdFusion Tutorial.
No User Comments.
No User Comments, be the first one to write your comments?
