How to call member functions within a class? |
This is my original code:
Code: Then I took out first two lines and put them in a separate function with the purpose of lessen lines of code and to try calling a member function. Code: private function load_head_page() And then: Code: else But it's giving me a fatal error saying header.php is undefined...
Can you paste the full error here? If your header.php is in the right folder structure to be found, maybe it's the $page variable in your load_head_page that is undefined and the error trace is just near the included header.php file.
(03-17-2015, 11:48 AM)logsdon Wrote: Can you paste the full error here? If your header.php is in the right folder structure to be found, maybe it's the $page variable in your load_head_page that is undefined and the error trace is just near the included header.php file. Oh, ok so I guess Im calling load_head_page() correctly? That's what I was worried about. Thank you.
The code works only if I include $this->load->helper('url'); in all functions one by one, but it doesnt work when I include it in the constructor like this:
Code: function _construct()
May I suggest another, imo, a bit simpler and cleaner solution for you.
Instead of breaking out the view loading of the header and page, just set the footer template name in a variable. Start by setting a default template, the regular footer used on all pages except contact us page. If the page is contact us, we just change the footer template variable to what footer we want to load. Here is an example PHP Code: public function view($page = "index") Also, just a small note, you don't need to include .php file ending.
|
Welcome Guest, Not a member yet? Register Sign In |