<cfinclude>
tag. By calling includePartial() or renderPartial(), you can include other view files in a page, just like <cfinclude>
would. But at the same time, partials make use of common Wheels features like layouts, caching, model objects, and so on.<cfinclude>
a lot in the past (and who hasn't?!), you probably already knew all of this though, right?views
folder. When locating partials, Wheels will use the same rules as it does for the template
argument to renderView(). This means that if you save the partial in the current controller's view folder, you reference it simply by its name.blog
controller, you would save the file at views/blog/_comment.cfm
and reference it (in includePartial() and renderPartial()) with just "comment
" as the first argument.views
folder. To reference partials in this folder, in this case named shared, you would then pass in "/shared/banner"
to includePartial() instead._banner.cfm
in the current controller's view folder and include it.blog
controller. Then the file that will be included is views/blog/_banner.cfm
..cfm
part or the underscore when referencing a partial.partial
argument to determine what file to include, you can't pass in a variable named partial though. The same goes for the other arguments as well, like layout
, spacer
, and cache
.arguments.title
inside the _loginregisterform.cfm
file.arguments
struct (which means less chance of strange bugs occurring due to variable conflicts). It also makes for more readable and maintainable code. (You can see the intent of the partial better when you see what is passed in to it).query
, object
and objects
arguments are special arguments and should not be used for other purposes than what's documented in the sections further down on this page.private
and will return a struct). If so, the partial will call the function and add the output returned to its arguments
struct.dataFunction
argument to includePartial() and renderPartial().layout
argument, like this:views/boxes/_blue.cfm
. Just like with other layouts, you use includeContent() to represent the partial's content._blue.cfm
file could end up looking something like this:cache
argument.cust
variable contains a customer
model object. It will then try to include a partial named _customer.cfm
and pass in the object's properties as arguments to the partial. There will also be an object
variable available in the arguments
struct if you prefer to reference the object directly.<cfdump>
the arguments
struct inside the partial file, and you'll see what's going on. Pretty cool stuff, huh?_customer.cfm
partial on each iteration. Similar to the example with the object above, Wheels will pass in the objects' properties (in this case represented by records in the query) to the partial.current
and is available when passing in queries or arrays of objects to a partial.spacer
argument. Anything passed in to that will be inserted between iterations. Here's an example:group
, which contains the albums for the current artist in the loop.