Navigation like a site without framework |
[eluser]Dyllon[/eluser]
[quote author="brianw1975" date="1265460846"] ...just like most women can have more than one child... a controller can load more than one view. [/quote] Although it's true, that is probably the strangest programming comparison I have ever heard.
[eluser]brianw1975[/eluser]
[quote author="Dyllon" date="1265502303"][quote author="brianw1975" date="1265460846"] ...just like most women can have more than one child... a controller can load more than one view. [/quote] Although it's true, that is probably the strangest programming comparison I have ever heard.[/quote] lol, I've got a million of them... that one just popped into my mind when i was writing that post. i usually use a car or home construction metaphor, but none seemed as well suited. I mean.. i just sounds better than "Home Depot has more than one Drill, so can you" -- know what i mean?
[eluser]Dyllon[/eluser]
just like a garage can house multiple cars, your controllers can load multiple views.... I guess the women have multiple children thing is a little more fitting for the scenario, there's got to be a robot metaphor in here somewhere.
[eluser]Haskabab[/eluser]
I just came across some templating libraries. Is it advisable to use one of those? I'm afraid that if I use one of those now I'll never understand how to do it manually.
[eluser]SpooF[/eluser]
Just going to through this in here: http://github.com/benedmunds/CodeIgniter-MY_Controller
[eluser]Haskabab[/eluser]
[quote author="SpooF" date="1265510532"]Just going to through this in here: http://github.com/benedmunds/CodeIgniter-MY_Controller[/quote] Ehm thanks? What's that
[eluser]SpooF[/eluser]
Its an extension of the CodeIgniter controller by Ben Edmunds. I mainly use it for my views. The idea behind a MY_Controller is to allow you add anything you want to all your controllers with out copy & pasting it into every single one. If you have a common function you use through out them all, or if you need to set a variable. I mainly posted this for the render function. Code: protected function render($template='main') { This allows you to have a shell for all your pages, it then will insert based upon the current controller and method/action/function. Your main template is in applications/views/layouts/ by default this is going to be called main.tpl.php. All your other views will be under application/views/[controller_name]/[method/action/function].tpl.php Then all you have to do is call $this->render() and it does all the template stuff for you. Data is stored in $this->data Example: Code: $this->data['title'] = 'My Page Title'; This MY_Controller also has some other functionality to it, but you can look into that your self.
[eluser]Haskabab[/eluser]
Thanks a lot for the explanation! I completely understand it now and I've just finished my template system and it's all up and running . Thanks for replying guys ^^ ~Nick |
Welcome Guest, Not a member yet? Register Sign In |