Welcome Guest, Not a member yet? Register   Sign In
PHP Includes
#1

[eluser]bhbutter123[/eluser]
I am liking the idea of codeigniter but am new to MVC mentality. I would like to keep part of my site done the same way as I used to just because it was easy and I think it is impossible to do with MVC, please prove me wrong. What I would do is set an index.php file and that would have the "framework" of the site. This would include the head of the site as well as include sections for the navigation and header. Then there would be a section that took a $_GET variable and based on the variable it would know what page to include. Under codeigniter it looks to be that I have to have all of the html in the view pages so each view would have a head and a section for the header and navigation includes like I had before. This is cumbersome because before I was able to click on the page I wanted to view the page of in my text editor and all that would be on that document was the content for that page and nothing else. Is this way of doing things possible with codeigniter?
#2

[eluser]BrianDHall[/eluser]
Check out the wiki entry on this: http://codeigniter.com/wiki/Header_and_f...very_page/

I basically use a class variable of $this->data that I pass to all my views. I load a "view partial" with my content into $this->content, which I alias with a reference of $this->data['content'] =& $this->content.

Then in my 'master template' for the whole page I just have an echo $content in my view, which is part of the $this->data array I pass to my all/most of my views.

The wiki details how this works, and I've been meaning to put my take on there but haven't gotten around to revising it. Basically I use my controller's constructor for these sorts of header/footer initializations, but you can just as well use a MY_controller - same basic principle.

None of this violates MVC. Indeed, nothing in MVC dictates you can only use one View.




Theme © iAndrew 2016 - Forum software by © MyBB