Welcome Guest, Not a member yet? Register   Sign In
MVC Question
#1

[eluser]codeman[/eluser]
Hi Guys,

When you say that Code-Igniter uses the MVC approach and calls things only when needed makes it faster and less bulky

Does that mean when i When i use this http://localhost/index.php/blog/name - it only performs name(), or comment() or index(). It does not load the whole blog page?

Is this true? Does it load the whole page? if yes then what you mean by loading things when needed?

Code:
<?php
class Blog extends Controller {
    
    function __contruct(){
        parent::Controller;
    }
    
    function index()
    {
        echo 'Hello World!';
    }

    function comment(){
        echo "Comments are shown below";
    }
    
    function name(){
        echo "Put you Name";
    }
}
?>
#2

[eluser]Thorpe Obazee[/eluser]
What do you mean by 'not load the whole blog page'?

Code:
http://localhost/index.php/blog/name
would run, blog/name, yes.

Loading things when needed is because you can load libraries and helpers like, the cart, ftp, image manilapulation, etc as your are executing via $this->load.

That's probably one of the reasons why it's so fast. less automagic unlike 'Cake'.
#3

[eluser]NogDog[/eluser]
The blog.php controller file would be included, so if that's what you mean by "loaded", then yes, it is "loaded"; but only the __construct() and name() methods would be executed (unless either of those methods executed other methods).
#4

[eluser]Thorpe Obazee[/eluser]
OT: Hmm.. 2 dogs one page :p
#5

[eluser]NogDog[/eluser]
[quote author="bargainph" date="1240899925"]OT: Hmm.. 2 dogs one page :p[/quote]
Wanna make puppies? Wink

(Actually, since Noggin is neutered, that may be a bit difficult regardless of whether or not your dog is female. :bug: )
#6

[eluser]Thorpe Obazee[/eluser]
[quote author="NogDog" date="1240904671"]
(Actually, since Noggin is neutered, that may be a bit difficult regardless of whether or not your dog is female. :bug: )[/quote]

aaawww...

rofl.
#7

[eluser]Zeeshan Rasool[/eluser]
Nice question, look blog loads the page/view which you're given,so we have to load some data or have to show some record according to our function.So, comments() will load comments of blogs in view and same is with name().
#8

[eluser]xwero[/eluser]
codeman if you are talking about the physical loading of files the whole blog.php file is loaded. MVC doesn't do magical tricks.
#9

[eluser]Dam1an[/eluser]
I think the original question was refering more to the fact that CI doesn't load the entire stack (all the libraries, helpers etc) for you, but only the parts that you need (and specify)
#10

[eluser]Thorpe Obazee[/eluser]
[quote author="Dam1an" date="1240923141"]I think the original question was refering more to the fact that CI doesn't load the entire stack (all the libraries, helpers etc) for you, but only the parts that you need (and specify)[/quote]

Yep. that was what I think he was trying to say.




Theme © iAndrew 2016 - Forum software by © MyBB