Created
March 15, 2017 18:54
-
-
Save neokoenig/a136cecef508506503fa5a026a2fc782 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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)# |
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
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.