Auto-load webpage structure |
[eluser]Ci beginner[/eluser]
Hello forum! I've read the documentation but I didn't find the right way to force to load a default structure in a webpage on every view. I mean, for instance, if I got this structure: Code: <html> Instead of writing always the same thing in every view, I want to load it automatically. I thought on making a function like do_header() and do_footer() but I don't know if it will be the best way to do it. And to finish, I'm starting with CI and all I can say for now... it's the best framework I have ever seen: simply, easy, lightweight... long life, CI! Thank you very much in advance! Note: the [removed] thing was a "script src" tag but the forum deleted it.
[eluser]John_Betong[/eluser]
Search the forums for "Partial views"
[eluser]Ci beginner[/eluser]
[quote author="John_Betong" date="1248674769"] Search the forums for "Partial views" [/quote] Nice, I found something. I probably make a library/helper/something with do_header() and do_footer(), put in autoload and then, call it from views. Thank you!
[eluser]InsiteFX[/eluser]
Hi, You need to create different views for the html web page. header_view.php content_view.php footer_view.php these shoud be in your CodeIgniter application views folder. then in your html web page add tese views to it. And this is how you pass data to your view. Code: <?php html you will add these were they belong Code: <?php $this->load->view('header_view'); ?>
[eluser]Ci beginner[/eluser]
[quote author="InsiteFX" date="1248683356"]Hi, You need to create different views for the html web page. header_view.php content_view.php footer_view.php these shoud be in your CodeIgniter application views folder. then in your html web page add tese views to it. And this is how you pass data to your view. Code: <?php html you will add these were they belong Code: <?php $this->load->view('header_view'); ?> I didn't fully understand but I'll try it, thank you very much!
[eluser]wowdezign[/eluser]
This thread has an explanation of how to do a simple type of templating. http://ellislab.com/forums/viewthread/124268/
[eluser]Ci beginner[/eluser]
[quote author="wowdezign" date="1248712500"]This thread has an explanation of how to do a simple type of templating. http://ellislab.com/forums/viewthread/124268/[/quote] I'm very grateful, thank you, really! This helps me a lot. That was the thread I wanted :-)
[eluser]Ci beginner[/eluser]
Hey guys! I noticed that using "hooks" is the best way to make this - well, maybe not the best, but the easier. But I have a little issue, how to put a title for every view? I mean, the hooks let me call any function from a class in different times (before loading the controller, after, when the page is loaded and sent...), but I'm unable to send the right title for the header. Any ideas? Thank you!
[eluser]InsiteFX[/eluser]
Ci beginner, If you look at the code I posted above it will show how to set the title in your views. Look at the index function/method $data Enjoy InsiteFX
[eluser]wowdezign[/eluser]
[quote author="Ci beginner" date="1248807583"]But I have a little issue, how to put a title for every view?[/quote] Do mean that you need to know how to do it with hooks or the way we were describing? |
Welcome Guest, Not a member yet? Register Sign In |