Formtools Object Admin

Build a Content Listing Page

Building a page to list the content items for a specific content type is simplicity itself.

  • Create a dedicated controller under your project folder: ./yourprojectfolder/customadmin/mymodule/typename.cfm (I've found that ./yourprojectfolder/customadmin/customlists/typename.cfm seems to be work best).
  • Add the ft:objectadmin custom tag to your controller (see below)
  • Reference the page in the webtop by updating your ./customadmin/customadmin.xml file

Defining the Listing Page

You only need to use the objectadmin custom tag, located in the ./core/tags/formtools library.

Useful attributes:

Attribute

Description

Value

Version

title

The title of the page

Defaults to "#attributes.typename# Administration"

typename

The typename

Defaults to ""

ColumnList

List of the columns to be displayed

Defaults to "label,datetimelastupdated"

aCustomColumns

Array holding data for rendering the cells

Defaults to empty array

SortableColumns

list of the properties the user will be able sort on

Defaults to ""

lFilterFields

list of the properties the user will be able filter on

Defaults to ""

sqlorderby

default sorting SQL expression

Defaults to "datetimelastupdated desc"

sqlWhere

Define a where clause filter. This filter will always be applied to the data provider for the object admin.

No filter applied by default. For example, status IN ('draft', 'pending') would only show draft and pending content items.

lCustomActions

Custom list of actions to appear in the Action drop-down.

For example - duplicate:Duplicate,remove:Remove Me

stFilterMetaData

Structure of formtool metadata passed in to filter form.

For example, use this if you want to change the edit behaviour of a property specifically for the filter area of object admin.

bSelectCol

Show the select checkbox column. You need this to interact with the default buttons except add.

Defaults to true

 

bShowActionList

Show the drop down list of actions.

Defaults to true

4.0.7

./customadmin/mymodule/mylisting.cfm
<!--- import tag libraries --->
<cfimport taglib="/farcry/core/tags/formtools" prefix="ft" />
<cfimport taglib="/farcry/core/tags/admin/" prefix="admin" />

<!--- set up page header --->
<admin:header title="Users Listing" />

<ft:objectAdmin
	title="my custom listing page"
	typename="myTypeName"
	ColumnList="fullname,datetimelastUpdated,PublishDate,CompanyID"
	SortableColumns="fullname,datetimelastUpdated"
	lFilterFields="fullname,userCategory"
	sqlorderby="datetimelastupdated desc" />

<!--- page footer --->
<admin:footer />

Custom Actions

Custom actions is a comma delimited list of variable:value pairs. The variable becomes the form post action and the value the visible list item.

The action posts back to the objectadmin page and can be trapped using ft:processForm.

<ft:processForm action="myaction">

   <!--- your custom code goes here --->

</ft:processForm>

Reserved Action Events

The following Event actions are reserved for use by the underlying objectadmin tag:

  • delete
  • unlock
  • apply filter
  • clear filter
  • add
  • overview
  • edit
  • view
  • flow
  • requestapproval
  • approve
  • createdraft

Custom Columns or Cell Renderers

You can build a webskin to render content for each content item in a nominated cell of the content listing grid; often called a cell renderer.

The aCustomColumns is an array of struct with the following keys:

  • title : column header (takes HTML)
  • webskin : webskin used to render the cell
  • sortable : optional boolean, if you want the user be able to sort the column on the column
  • property : mandatory if sortable=true

Examples:

Object Admin Custom list example
<cfimport taglib="/farcry/core/tags/formtools" prefix="ft" />
<cfimport taglib="/farcry/core/tags/admin/" prefix="admin" />

<!--- set up page header --->
<admin:header title="Users Listing" />

<cfscript>
	aCustomColumns = arrayNew(1);
	aCustomColumns[1] = structNew();
	aCustomColumns[1].webskin = "showThumbnail.cfm"; // located in the webskin of the type the controller is listing on
	aCustomColumns[1].title = "thumb";
	aCustomColumns[1].sortable = true; //optional
	aCustomColumns[1].property = "imageUrl"; //mandatory is sortable=true
</cfscript>

<ft:objectAdmin
	title="my custom listing page"
	typename="myTypeName"
	ColumnList="fullname,datetimelastUpdated,PublishDate,CompanyID"
	aCustomColumns="#aCustomColumns#"
	SortableColumns="fullname,datetimelastUpdated"
	lFilterFields="fullname,userCategory"
	sqlorderby="datetimelastupdated desc" />

<admin:footer />

Note you don't need to include a "cell renderer" (aka custom column) in the ColumnList attribute. Custom columns are shown first in the grid in array order.

Custom Filter Metadata

The filter form is built using the same formtool technology used to render your edit handler. As a consequence it inherits the same default properties you have defined for your edit handler, which may not be appropriate for the filter form. Fortunately you can easily override the formtool behaviour by passing in your own filter specific metadata.

./plugins/farcrycms/customadmin/dmnews.cfm
<cfimport taglib="/farcry/core/tags/admin" prefix="admin" />
<cfimport taglib="/farcry/core/tags/formtools" prefix="ft" />

<!--- remove validation --->
<cfset stFilterMetaData = StructNew() />
<cfset stFilterMetaData.title.ftValidation = "" />

<!--- set up page header --->
<admin:header title="News" />

<ft:objectadmin
typename="dmNews"
permissionset="news"
title="#application.adminBundle[session.dmProfile.locale].newsAdministration#"
columnList="title,catnews,publishdate,datetimelastUpdated"
sortableColumns="title,publishdate,datetimelastUpdated"
lFilterFields="title,source"
sqlorderby="publishdate desc"
plugin="farcrycms"
stFilterMetaData="#stFilterMetaData#"
module="/dmNews.cfm" />

<!--- setup footer --->
<admin:footer />