Skip to content

Instantly share code, notes, and snippets.

<cffunction name="filters" returntype="void" access="public" output="false"
hint="Tells Wheels to run a function before an action is run or after an action has been run. You can also specify multiple functions and actions."
examples=
'
<!--- Always execute restrictAccess before all actions in this controller --->
<cfset filters("restrictAccess")>
<!--- Always execute isLoggedIn and checkIPAddress (in that order) before all actions in this controller except the home and login action --->
<cfset filters(through="isLoggedIn,checkIPAddress", except="home,login")>
'
<!--- cfwheels snippet
Description:
--->
<cfset test = "I am a snippet for Wheels" />
<cfcomponent extends="Controller" output="false">
# ...
<cffunction name="show">
<!--- Find the record --->
<cfset entry = model("Entry").findByKey(params.key)>
# ...
</cffunction>
<cffunction name="edit">
<cfcomponent extends="Controller" output="false">
<cffunction name="show">
<cfset student = model("Student").findByKey(key=1, include="Enrollments") />
<cfset course = model("Course").findByKey(key=2, include="Enrollments") />
</cffunction>
</cfcomponent >
<!--- on initial request, run query --->
<cfset "session.#attributes.myactionfile#" = "" />
<cfsavecontent variable="datasorter_js">
<style type="text/css" title="currentStyle">
@import "css/datatables_table.css";
</style>
<script type="text/javascript" language="javascript" src="js/jquery.dataTables.min.js"></script>
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
@mhenke
mhenke / run.cfm
Created September 26, 2010 18:43
<!---
Let's generate our default HTML documentation on Wheels:
--->
<cfscript>
version = "1.0.5";
wheels = createObject("component", "ColdDoc").init();
strategy = createObject("component", "colddoc.strategy.api.HTMLAPIStrategy").init(
expandPath("docs"),
"ColdFusion On Wheels #version#");
<!--- place in views/say folder --->
<cfoutput>
#javaScriptIncludeTag("jquery-1.4.2.min")#
</cfoutput>
<script language="JavaScript">
// Listen to the "click" event of the "alert-button" link and make an AJAX request
$(document).ready(function(){$("#alert-button").click(function() {
$.ajax({
type: "POST",
<!--- place in /controllers folder--->
<cfcomponent extends="Controller">
<cffunction name="getdemo" returntype="Query" access="private" >
<cfset var entries = model("entry").findAll(select="BODY,CATEGORYID,TITLE,dateCreated") />
<cfreturn entries />
</cffunction>
<cffunction name="init">
<cfset filters(through="turnOffDebugging",only="processing")>
@mhenke
mhenke / captcha.cfm
Created December 27, 2010 21:11
captcha custom tag
<!---
This will create two variables for the page too be outputted:
OUTPUT:
CAPTCHA_DISPLAY - captcha fields/image
CAPTCHA_ERROR - error message of captcha failure
blnIsBot - is this a bot
http://www.bennadel.com/blog/873-Using-CAPTCHA-In-ColdFusion-8.htm
--->
@mhenke
mhenke / js_validation_not_working.html
Created February 10, 2011 02:28
validation for js not working
<html>
<body>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>ValidateThis! Demo Page</title>
<link href="/stylesheets/demostyle.css" media="all" rel="stylesheet" type="text/css" />
<link href="/stylesheets/uni-form-styles.css" media="all" rel="stylesheet" type="text/css" />