Try searching this group[1]. I did it for you and found [2] [3] among others.
Hope that helps. -- Pablo Viojo [EMAIL PROTECTED] http://pviojo.net [1] http://groups.google.com/group/cake-php/search?hl=en&group=cake-php&q=app_controller+model [2] http://groups.google.com/group/cake-php/browse_thread/thread/33ca0358e2854908/68783b79936b4e4e?hl=en&lnk=gst&q=app_controller+model#68783b79936b4e4e [3] http://groups.google.com/group/cake-php/browse_thread/thread/e299ac5f67ef50cb/0bfb60fdc7895753?hl=en&lnk=gst&q=app_controller+model#0bfb60fdc7895753 On Dec 28, 2007 4:48 PM, carSign <[EMAIL PROTECTED]> wrote: > > I am getting close. > My beforeFilter function in the app controller is being called on each > page (just like I want) but it seems to have trouble running something > in a model. > Anyone have any ideas on what I am doing wrong. > > app_controller.php > > <?php > class AppController extends Controller { > var $helpers = array('Html', 'Form', 'Javascript'); > > function beforeFilter() > { > $this->AppModel->carSign(); > return true; > } > } > ?> > > > > app_model.php > <?php > class AppModel extends Model{ > > function carSign() > { > //make an entry into the database > echo 'wonkey'; > } > } > ?> > > Here is the error > > Notice: Undefined property: PagesController::$AppModel in /home/y/ > share/htdocs/cake/app/app_controller.php on line 7 [/index.php] Fatal > error: Call to a member function carSign() on a non-object in /home/y/ > share/htdocs/cake/app/app_controller.php on line 7 [/index.php] > > > > On Dec 21, 8:51am, daphonz <[EMAIL PROTECTED]> wrote: > > Sure. You can use the controller callback functions in app_controller, > > listed here:http://tempdocs.cakephp.org/#TOC52711 > > > > So try doing something like: > > > > function beforeFilter() > > { > > > > /* Super controller logic that accesses a function in app_model or > > something */ > > return true; > > > > } > > > > If you need to access a model every time you run a controller action, > > you may want to add: > > > > var $uses('NecessaryModel'); > > > > to your app_controller as well. > > > > -Casey > > > > On Dec 21, 10:33 am, carSign <[EMAIL PROTECTED]> wrote: > > > > > > > > > Hi - > > > > > So I am trying to include a small snippet of code in each page of my > > > site. Is there a way to do this without modifying each controller? > > > > > For example - I want to log visitors to my site. Each page visited > > > would have some information put into the database. > > > > > URL > > > User info > > > tiestamp > > > browser info > > > > > Can I do this using the app_controller? Can it be done without the > > > need to modify all of my existing controllers? > > > If I include it in the app_controller do I name that action 'index'? > > > do I then create a app_model?- Hide quoted text - > > > > - Show quoted text - > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---
