Skip to content

Instantly share code, notes, and snippets.

@chrisdpeters
Created February 15, 2012 22:55
Show Gist options
  • Save chrisdpeters/1839803 to your computer and use it in GitHub Desktop.
Save chrisdpeters/1839803 to your computer and use it in GitHub Desktop.
404 Error Handling in CFWheels
<cffunction name="render404" hint="Renders a 404 error page.">
<cfset renderPage(controller="main", action="error404")>
</cffunction>
<cfset layout.title = "Page Not Found | ColdFusion on Wheels">
<cfset layout.header1 = "Page Not Found">
<cfset layout.breadcrumbs = ["Page Not Found"]>
<!--- 404 error --->
<cfheader statuscode="404" statustext="Not Found">
<cfoutput>
<p>
We're sorry. We couldn't find the page that you're looking for. It has either been removed, or perhaps
you are accessing an inaccurate <abbr title="Uniform Resource Locator">URL</abbr>.
</p>
<h2><label for="search-query-404">Search</label></h2>
#startFormTag(controller="search", id="cse-search-box", method="get")#
<div>
<input type="hidden" name="cx" value="005724978648843866544:jpej79qhz14" />
<input type="hidden" name="cof" value="FORID:10" />
<input type="hidden" name="ie" value="UTF-8" />
<input id="search-query-404" type="text" name="q" />
<input type="submit" name="sa" value="Search" />
</div>
#endFormTag()#
<h2>Start from the Home Page</h2>
<p><strong>#linkTo(text="ColdFusion on Wheels Home &raquo;", route="home")#</strong></p>
</cfoutput>
<cffunction name="profile" hint="Displays user profile.">
<cfset user = model("customer").findByKey(params.key)>
<cfset loggedInUser = getLoggedInCustomer()>
<!--- If profile found, show it --->
<cfif IsObject(user)>
<cfset sites = user.sites(where="isApproved=1")>
<cfset plugins = user.plugins(where="isApproved=1")>
<!--- 404 error if not found --->
<cfelse>
<cfset render404()>
</cfif>
</cffunction>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment