I’ve made a footer element that will be shown throughout my entire website.
The content of this page needs to be filled up with data from a certain model, on every page it is shown.
$sponsors = $this->Sponsor->find('all',
array('conditions' => array("NOT" => array("Sponsor.logo_id" => null))));
But where is the best place to define this? I thought in the app_controler, but how to do so isn’t exactly clear to me.
In your
AppController‘sbeforeFilteror possiblybeforeRender(I never really noticed the difference); making sure yourAppControllerhas access toSponsormodel.You now have access to
$sponorsin any view.And it may be best to place the data in to an element and cache it for a suitable amount of time to avoid constantly having to query the database (depending on other factors such as page load/other intensive queries etc.