Sometimes the built-in methods are insufficient for a given site. You may need to call aspects of a layout from within a page, for example, or you might want to set content outside of the main content area from a page.
For these kinds of situations, you would want to use a custom method.
Here are examples of each kind of custom method:
To use an ouput method, simply call it wherever you want it to appear on the page. For example, if you want your menu to appear after some content:
<cfoutput>#layout.head("Page Title")#</cfoutput>
<cfoutput>#layout.body()#</cfoutput>
(some content here)
<cfoutput>#layout.menu()#</cfoutput>
(more content here)
<cfoutput>#layout.end()#</cfoutput>
If the method takes arguments, then just pass them normally in this syntax.
<cf_layout title="Page Title">
<cf_layout>
(some content here)
<cf_layout action="menu">
(more content here)
<cf_layout>
If the method takes arguments, then just pass them as attributes to the tag.
If you need to add images to a side bar, for example, you might have an "addSideBarImage" method.
<cfset layout.addSideBarImage(src="/images/myimage.jpg",alt="My Image")>
<cfset layout.addSideBarImage(src="/images/myimage2.jpg",alt="My Second Image")>
<cfoutput>#layout.head("Page Title")#</cfoutput>
<cfoutput>#layout.body()#</cfoutput>
(some content here)
<cfoutput>#layout.menu()#</cfoutput>
(more content here)
<cfoutput>#layout.end()#</cfoutput>
<cfset layout.addSideBarImage(src="/images/myimage.jpg",alt="My Image")>
<cfset layout.addSideBarImage(src="/images/myimage2.jpg",alt="My Second Image")>
<cf_layout title="Page Title">
<cf_layout>
(some content here)
<cf_layout action="menu">
(more content here)
<cf_layout>
<cf_layout action="addSideBarImage" src="/images/myimage.jpg" alt="My Image">
<cf_layout action="addSideBarImage" src="/images/myimage2.jpg" alt="My Second Image">
<cf_layout title="Page Title">
<cf_layout>
(some content here)
<cf_layout action="menu">
(more content here)
<cf_layout>