{"action":"created","issue":{"url":"https://api.github.com/repos/panique/php-login/issues/557","labels_url":"https://api.github.com/repos/panique/php-login/issues/557/labels{/name}","comments_url":"https://api.github.com/repos/panique/php-login/issues/557/comments","events_url":"https://api.github.com/repos/panique/php-login/issues/557/events","html_url":"https://github.com/panique/php-login/issues/557","id":54346919,"number":557,"title":"Header and Footer Question","user":{"login":"johnnydevs","id":8192228,"avatar_url":"https://avatars.githubusercontent.com/u/8192228?v=3","gravatar_id":"","url":"https://api.github.com/users/johnnydevs","html_url":"https://github.com/johnnydevs","followers_url":"https://api.github.com/users/johnnydevs/followers","following_url":"https://api.github.com/users/johnnydevs/following{/other_user}","gists_url":"https://api.github.com/users/johnnydevs/gists{/gist_id}","starred_url":"https://api.github.com/users/johnnydevs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/johnnydevs/subscriptions","organizations_url":"https://api.github.com/users/johnnydevs/orgs","repos_url":"https://api.github.com/users/johnnydevs/repos","events_url":"https://api.github.com/users/johnnydevs/events{/privacy}","received_events_url":"https://api.github.com/users/johnnydevs/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-01-14T16:59:00Z","updated_at":"2015-01-14T19:17:00Z","closed_at":"2015-01-14T18:33:47Z","body":"Firstly thank you to everyone for all the hard work, I am gradually building upon this framework in order to build a library app. I am quite new to php and this is a great way for me to further my personal development. I am able to create new pages, load models, and render views etc, however I am a bit unclear about the header and footer - these aren't views are they? They don't behave like the rest of the files as regards loading/calling functions.\r\n\r\nI'll give an example, I have a table called favourite which contains basic user and book details. I have a query which counts the number of rows in this table and displays it on the views/login/showprofile.php page as a small notification \"You have this number of favourites\"  (in the header section I created a new div on the right hand side).\r\n\r\nIn order to do this I created a function favouriteTotal() in my login model - see below\r\n\r\n    public function favouriteTotal()\r\n    {\r\n        ... query ...\r\n\r\n        $fav = array();\r\n        foreach ($query->fetchAll() as $favs) {   \r\n            $fav[$favs->id] = new stdClass();\r\n            $fav[$favs->id]->book_id = $favs->book_id;\r\n        }\r\n        return $fav;\r\n    }\r\n\r\nI then created a function in my login controller - see below\r\n\r\n    function showProfile()\r\n    {\r\n        Auth::handleLogin();\r\n        $login_model = $this->loadModel('Login');\r\n        $this->view->Favcount = $login_model->favouriteTotal();\r\n        $this->view->render('login/showprofile');\r\n    }\r\n\r\nIn the application/views/_templates/header.php I added the following code\r\n\r\n    \"You have this number of favourites\" <?php echo count($this->Favcount); ?>\r\n\r\nThis works perfectly, but only on the showprofile.php page. When I move to any other page I receive an error Notice:  Undefined property: View::$Favcount in C..\\application\\views\\_templates\\header.php on line 151.\r\n\r\nAm I missing something or doing something very silly? I appreciate any help. Still learning!\r\n\r\nRegards,\r\nJohnny\r\n\r\n\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/panique/php-login/issues/comments/69973537","html_url":"https://github.com/panique/php-login/issues/557#issuecomment-69973537","issue_url":"https://api.github.com/repos/panique/php-login/issues/557","id":69973537,"user":{"login":"johnnydevs","id":8192228,"avatar_url":"https://avatars.githubusercontent.com/u/8192228?v=3","gravatar_id":"","url":"https://api.github.com/users/johnnydevs","html_url":"https://github.com/johnnydevs","followers_url":"https://api.github.com/users/johnnydevs/followers","following_url":"https://api.github.com/users/johnnydevs/following{/other_user}","gists_url":"https://api.github.com/users/johnnydevs/gists{/gist_id}","starred_url":"https://api.github.com/users/johnnydevs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/johnnydevs/subscriptions","organizations_url":"https://api.github.com/users/johnnydevs/orgs","repos_url":"https://api.github.com/users/johnnydevs/repos","events_url":"https://api.github.com/users/johnnydevs/events{/privacy}","received_events_url":"https://api.github.com/users/johnnydevs/received_events","type":"User","site_admin":false},"created_at":"2015-01-14T19:16:59Z","updated_at":"2015-01-14T19:16:59Z","body":"Thank you for that. I appreciate you taking the time to comment. That information helps, and yes I do want the data to be available in ALL views as it is a header notification area. I suppose I can do this manually for each view as the amount of pages I have is manageable. Thanks again @panique"}}