Please help Views and routes |
[eluser]Sveeaa[/eluser]
Sorry for this. i really dont know what to search for i tried for 2 days. I wanna know have to changes views with links or buttons. Code: function index() to maybe view_page2 I wanna keep the header and foot always. my header loads html body and my footer closes them. so my view_page is only <div> and stuffs like that. or do i have to have header och footer in some kind of global controller? and routes i saw that you can make your own ones. $route['default_controller'] = "page1"; <-defalt one; if i would make one like $route['cool'] = "page2"; <-defalt one; <- how can i use it? sorry for beeing a newbie but im trying to understand it. best regards Svea
[eluser]whobutsb[/eluser]
Hi there, You might want to try this strategy. Create a view file called "template.php". In your template make this the skeleton of your page that will have all the normal HTML elements: Code: <html> In your controller you could write it like this: Code: function index(){ This is typically how I organize my CI projects.
[eluser]Sveeaa[/eluser]
thanks for that help. but i dont think thats what i really were looking for. I wanna be able to change view file and still keep the structure of the site. and dont have like structure in all my view files.
[eluser]cahva[/eluser]
I dont know why people want to separate header and footer from the layout. I mean, how often does the structure of header and footer actually change? Not very often. Using simple layout(or template whatever you wanna call it) where you just put place holders will be just as good: Code: <!DOCTYPE HTML> Best way to use base controllers is described in this link(this must be 1000 time I post this link): http://philsturgeon.co.uk/news/2010/02/C...ing-it-DRY Base(using the __autoload() magic function described in the link) and page controllers would be something like this: libraries/Front_controller.php Code: class Front_controller extends Controller { controllers/somepage.php Code: class Somepage extends Front_controller { Ofcourse normally you would have some loading of libraries and models +other stuff but thats the basic idea. Using separate header and footer views is just confusing as 99.7% of the time they will be the same so why not put them to main layout. And if you need different header or footer, just create a new layout view file.
[eluser]Sveeaa[/eluser]
Thank you. sorry that you have to post it so many times. yeah i kinda understood that you have to do it that way. and only think why i wanted to have seperate healder and footer where because i thought i could change the "main" view easier. What i really wanna now is how do i change the content. Code: function index() how could a navigation look to get to that function foo. :S best regards Svea
[eluser]Sveeaa[/eluser]
Quote:What i really wanna now is how do i change the content. that shouldnt be there. i wanna how how to navigate to function foo. i dont know how to explain myself when you enter my site all you will see is a login screen/view and when you press login enter another view/screen that i cant figure out how to do.. best regards Svea |
Welcome Guest, Not a member yet? Register Sign In |