Skip to content

Instantly share code, notes, and snippets.

<cfcomponent extends="Controller">
<!------------------------------------->
<!--- Public --->
<cffunction name="init">
<cfset filters(through="findPost", only="show,edit,update,destroy")>
</cffunction>
<cffunction name="show">
<!--- ... --->
@chrisdpeters
chrisdpeters / query-script.cfm
Created February 14, 2012 22:53
Full CFScript CFCs Aren’t Yet Where They Need To Be
local.queryService = new Query(datasource=get('dataSourceName'));
local.queryService.setSql("
SELECT DISTINCT
A.*
FROM
apps A
JOIN appgroupmemberships G
ON A.id = G.appid
WHERE
G.usergroupid IN (#local.groupIds#)
@chrisdpeters
chrisdpeters / Controller.cfc
Created February 15, 2012 22:55
404 Error Handling in CFWheels
<cffunction name="render404" hint="Renders a 404 error page.">
<cfset renderPage(controller="main", action="error404")>
</cffunction>
@chrisdpeters
chrisdpeters / autolink.cfm
Last active March 23, 2020 00:51
Using Extra CFC Attributes for Documentation
@chrisdpeters
chrisdpeters / Controller.cfc
Created February 16, 2012 22:49
Script-Based Controllers and Models, Tag-Based Views
component extends="Controller" {
/**
@hint Shows form for registering for social network.
*/
public function register() {
user = model("user").new();
}
/**
@chrisdpeters
chrisdpeters / gist:1848595
Created February 16, 2012 23:03
CFWheels Is Only a Hammer
$(document).ready(function(){
$(”.focus”).focus();
});
@chrisdpeters
chrisdpeters / _articles.cfm
Last active March 17, 2020 02:15
Aggregating RSS Feeds with Delicious, Yahoo! Pipes, FeedBurner, and CFML
<!--- URL to RSS feed --->
<cfparam name="arguments.articlesRss" type="url">
<!--- URL to Delicious page --->
<cfparam name="arguments.articlesUrl" type="url">
<!--- Number of items to display from feed --->
<cfparam name="arguments.numToDisplay" type="numeric" default="10">
<!--- Note: we are breaking the convention of data access in the view here so that we can cache this partial --->
<cfset articles = articles(arguments.articlesRss)>
@chrisdpeters
chrisdpeters / Call.cfc
Created February 23, 2012 21:13 — forked from tdm00/Call.cfc
Single Table Inheritance & Nested Properties
<cfcomponent extends="Model" output="false">
<cfset this.modelName = ListLast(GetMetaData(this).name, ".")>
<cffunction name="init">
<cfset table(name="calls")>
<!--- Validations --->
<cfset validatesPresenceOf(properties="callStatusId") />
@chrisdpeters
chrisdpeters / _layout_focus.cfm
Created February 23, 2012 22:50
Wheels + jQuery Partial for Setting Form Focus
<cfparam name="arguments.focus" type="string" default="">
<cfif Len(arguments.focus)>
<cfoutput>
<script type="text/javascript">
$(document).ready(function(){
$("#arguments.focus#").focus();
});
</script>
</cfoutput>
@chrisdpeters
chrisdpeters / Users.cfc
Created February 23, 2012 23:06
Improving the Tutorial: Using the Same View for Multiple Actions in CFWheels
<cffunction name="add">
<cfset user = model("user").new()>
<cfset header = "Create a New User">
<cfset formAction = "create">
<cfset submitLabel = "Create">
<cfset renderPage(template="form")>
</cffunction>
<cffunction name="edit">
<cfset user = model("user").findByKey(params.key)>