Layout Components 1.0 Documentation: Custom Methods

Layout Components Information

Download from RIA Forge

Blog Entries

Custom Methods

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:

Output 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:

Direct CFC Code:

<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.

Using cf_layout:

<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.

Data Method

If you need to add images to a side bar, for example, you might have an "addSideBarImage" method.

Direct CFC Code:

<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>

Using cf_layout (option 1):

<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>

Using cf_layout (option 2):

<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>