Skip to content

Instantly share code, notes, and snippets.

@neokoenig
Created March 15, 2017 18:54
Show Gist options
  • Save neokoenig/a136cecef508506503fa5a026a2fc782 to your computer and use it in GitHub Desktop.
Save neokoenig/a136cecef508506503fa5a026a2fc782 to your computer and use it in GitHub Desktop.
// In controller.cfc
function getStuff(){
myStuff=model("foo").findAll(order="name");
}
// Mycontroller.cfc
init(){
filters(through="getStuff", only="index");
}
index(){
// Index now has access to myStuff
}
// /views/mycontroller/index.cfm
#select(objectname="myObject", options=myStuff)#
@QuillDesign
Copy link

So another question with this one (sorry to drag this back up ... but I'm struggling).

IF I want call the query "mystuff" to run on EVERY page ...do I have to add the filter to EVERY controller? or is there a better way.
 

@QuillDesign
Copy link

QuillDesign commented Jul 10, 2017

I may have just figured it out ... if I put filters(through="getStuff") in the controller.cfc then it seems to fire for EVERYWHERE. but I guess I am still going to say - is this the correct way to do this?

Specifically if this is being called in the "layout" and will pull a category list.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment