Proper method for includes/requires and init script?? |
[eluser]brettalton[/eluser]
OOP Beginner Hi, I'm pretty new to OOP in general, let alone MVC/CodeIgniter, but the concept seems fantastic! Personally, I've been making website procedurally like so: Code: <?php Is there a good tutorial out there for people like me who modularize their website like so? I understand I can make each include a 'view', but to call them over and over again in every controller doesn't seem efficient. I could also make one template that holds my header, footer, menu, etc. but then what about my content? Each page surely will be different and not carry all the same code... Init Scripts If I have code in my 'home' controller that I want to be called for every single page (as it carries a redirect), where would I put it? Redirect Externally I had to create a helper at ./system/application/helpers/url_custom_helper.php containing: Code: <?php if (!defined('BASEPATH')) exit('No direct script access allowed'); just to redirect externally. Is there an external redirect function that I missed or was this necessary? Thanks so much for your time!
[eluser]maadmac[/eluser]
This is no doubt one of the most frequent questions that turns up in the forum; do some hunting around on 'partial views' -- esp. in the FAQ -- and you'll find what you're looking for. Off the top of my head, check out: Partial views 1 and Partial Views 2 Also see URL helpers in the UG for redirects: URL Cheers
[eluser]brettalton[/eluser]
I know this is an old thread, but in case anyone is reading, I want to add a link that really helped me: http://ellislab.com/forums/viewthread/59330/ |
Welcome Guest, Not a member yet? Register Sign In |