Creating Content Pages
Speck has two tags that can be used to retrieve content, cf_spContentGet and cf_spContent. Another tag that should also be used when creating content pages is the cf_spToolbar tag. This tag renders the admin toolbar when users are logged in and all pages should really contain a call to cf_spToolbar. This is generally done in a site-wide header file or layout file.
The cf_spContentGet tag retrieves Speck content and returns a query to the caller. This is similar to using the cfquery tag in CFML, but you don't actually write the query, just provide some attribute values.
The cf_spContent tag not only retrieves content but also renders it using the specified method. The cf_spContent tag also renders the administration links for managing content. In order to display the administration links embedded into the content pages, you must use the cf_spContent tag.
The cf_spContent tag calls the cf_spContentGet tag internally to retrieve content and all attributes passed to spContent are passed on to cf_spContentGet. This means that all cf_spContentGet attributes are also valid attributes for cf_spContent.
The following table lists the cf_spContent attributes used for rendering content, see cf_spContentGet for description of remaining attributes:
| Attribute | Type | Required | Description |
|---|---|---|---|
| method | String | No | Method called to display each item. If type doesn't implement method m, will attempt to call method m in default type. Default "display" |
| separator | String | No | If columns = 1, insert this html between each content item. Default "<br />" |
| columns | Number | No | If > 1, format content items in a table, order across then down. Default 1 |
| displayPerPage | Number | No | If > 0, show number of items per page and menu to page though results from cf_spContentGet |
| startRow | Number | No | The row in the query being rendered by spContent in which to start the output. Obviously, if this value is set to a row number greater than the number of rows returned by cf_spContentGet, nothing will be output. Default 1. |
| endRow | Number | No | The row in the query being rendered in which to end the content. This defaults to recordCount of the query, but if you know a little about the query being rendered, you can set the endRow to only output a set number of rows. If you set the startRow and endRow to the same value, only one row is ouput (which is handy for displaying random rows). If the attribute value isn't valid (gt recordCount or lt startRow), it will be ignored. |
| enableAdminLinks | Boolean | No | Display administration links for content items. Defaults according to showAdminLinks value for session, see cf_spToolbar |
| enableAddLink | Boolean | No | Display link to add content. Defaults to attributes.enableAdminLinks value |
| caption | String | No | Caption to use with admin links and in title of admin forms etc. Overrides caption from cf_spType and allows two or more instances of the same content type to be labelled differently on a page (e.g. as "header" and "footer"). |
The following table lists the attributes for the cf_spContentGet tag:
| Attribute | Type | Required | Description |
|---|---|---|---|
| r_qContent | String | Yes | Name of query variable to return results in |
| type | String | Yes | Name of content type to retrieve |
| id | List | No | Return one or more content items with these ids |
| label | String | No | Return content items with this exact label |
| keywords | List | No | Only return results with matching keywords |
| keywordsMatch | String | No | When used with keywords, return content matching all or any listed keywords. Value must be either "all", "any" or "exact", default "any" |
| where | String | No | Filter results with SQL where clause. Note, single quotes within this value are preserved when creating the SQL query so you need to make sure any single quotes within string literals are escaped. |
| orderby | String | No | Order results with SQL order by clause. |
| orderByIds | Boolean | No | If the id attribute contains a list of ids, order the results according to their position in the list of ids. This wee hack, along with the Picker property, allows Speck use simple lists to represent ordered collections. |
| maxRows | Number | No | Value passed as maxRows attribute in cfquery within cf_spContentGet. Default -1 (i.e. return all rows) |
| properties | List | No | Only retrieve values for listed properties rather than all properties. If used, only those properties listed are used in SQL SELECT column list and contentGet property handlers are only run for listed properties. This attribute can be used to optimise retrieval performance - see the performance optimisation section of the docs for more info. |
| cachedWithin | TimeSpan | No | Works the same way as the cachedWithin attribute of cfquery, although you do not need to enable the query cache in the ColdFusion administrator. Value must be a timespan created with the createTimeSpan() function. |
| revision | Number or String | No | revision number of content item to return, can specify "tip" to return most recent, or "all" to return all revisions. Note that specifying a particular revision number only makes sense when returning a single content item. Normally you will use the level attribute. The revision and level attributes cannot be used together. |
| level | String | No | Promotion level to retrieve content from. A promotion level ("edit", "review" or "live") is a revisioned view of the content object database used to determine which revisions of content are used. Each level can hold at most a single revision of each content item. New revisions of content are always created and modified at edit level, after which they can be 'promoted' to review, and then to live. Content revisions in review and live promotion levels are shared by all site users, whereas content revisions in edit levels are only visible to each editor. The revision and level attributes cannot be used together. |
| editor | String | No | Only required for edit level content to specify which editor's edit level to use. Defaults to current user |
| date | Date | No | Used to retrieve the revision of content that was at a specified promotion level or the tip revision on this date. |
| showRemoved | Boolean | No | When retrieving content by promotion level, return content revisions that have been removed from that promotion level. Default according to promotion level, true for edit and review, false for live. |
| filterRemoved | Boolean | No | Filter content revisions that have been removed from the next promotion level from the results. Has no effect if promotion level is live. Default true. |