-
-
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)# |
So I did exactly what you've suggested and I am then on the index view page and it is just showing function definition dump (you know that brown box) the one that says arguments none, returntype any etc,
its' not returning a query result
// Controller.cfc
private function getCountries() {
qCountry = model("countries").findAll(select="countryA2,name", where="active = 1");
}
// Addresses.cfc
public void function init() {
super.init();
filters(through="isAuthenticated,isAuthorized");
filters(through="$findAddress", only="show,edit,delete");
filters(through="getCountries", only="edit,new");
}
My /addresses/new.cfm
Are you dumping getCountries() or qCountry?
I have dumped getCountries / getCountries() and just tried qCountry and that is what I needed ... mercy ok that sheds a bit of light on some things.
Thank you.
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.
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.
Make sure it's
private function getStuff()