header and footer |
[eluser]tj[/eluser]
am new to ci frame work and to php .is there any way to add the header and footer to all views without repeting $this->load->view('header'); in all my controller. something like autoload hreader and footer. tnx in advance
[eluser]briskdeveloper[/eluser]
Hi, Even am looking for same thing If u find the solution for this plz let me know. Thanks, shakeeb
[eluser]N'hono[/eluser]
Hi ! For the header, there's a simple way to do it. You can create a "super" controller that heritated from Controller and that your others controller will be heritated. In the constructor of this "super" controller, you load the view "header". For example, Code: // file application/controller/SuperController.php But I tried the same for the footer in the desctructor method and it didn't work...Anybody has an idea ?
[eluser]briskdeveloper[/eluser]
hey did u tried the template system in codeigniter to solve this problem? shakeeb.
[eluser]tatewaky[/eluser]
[quote author="tj" date="1258132342"]am new to ci frame work and to php .is there any way to add the header and footer to all views without repeting $this->load->view('header'); in all my controller. something like autoload hreader and footer. tnx in advance[/quote] Hey i was wondering the same thing 3 days ago, and i found a great solution that works just great for me, i hope for you too. First: your controller index method: Code: $data['main_content'] = 'your_view'; And finally your template view: Code: <?php $this->load->view('header'); ?> i found this information on this video tutorial that also will help you with a login process
[eluser]jedd[/eluser]
[quote author="tj" date="1258132342"] am new to ci frame work and to php [/quote] Evidently. You may be fascinated to learn that we have a [url="/wiki/"]wiki[/url]. It has interesting articles in it, like [url="/wiki/Header_and_Footer_and_Menu_on_every_page_-_jedd/"]this one[/url].
[eluser]N'hono[/eluser]
[quote author="tatewaky" date="1258146400"][quote author="tj" date="1258132342"]am new to ci frame work and to php .is there any way to add the header and footer to all views without repeting $this->load->view('header'); in all my controller. something like autoload hreader and footer. tnx in advance[/quote] Hey i was wondering the same thing 3 days ago, and i found a great solution that works just great for me, i hope for you too. First: your controller index method: Code: $data['main_content'] = 'your_view'; And finally your template view: Code: <?php $this->load->view('header'); ?> i found this information on this video tutorial that also will help you with a login process[/quote] thanks a lot ! It was the one i didn't see yet ! I'm going to do it !
[eluser]Aken[/eluser]
I used a small Library I wrote to show a page with a header/footer. So my view file for that page is loaded in a way such as: Code: $this->template->view('view_name', $data); I also have some other features relating to a small amount of dynamic information in the header/footer, but that's not important. I found that doing things this way was less confusing as extending the core Controller class, and also allowed me to be more dynamic with my templates. For example, I have different header/footers for different parts of my website.
[eluser]jedd[/eluser]
[quote author="tj" date="1258132342"] is there any way to add the header and footer to all views [/quote] [quote author="tj" date="1258624503"] i just love this forum [/quote] I hope you've also learned to love the [url="/wiki"]wiki[/url], especially the [url="/wiki/FAQ"]FAQ[/url], even more. |
Welcome Guest, Not a member yet? Register Sign In |