Welcome Guest, Not a member yet? Register   Sign In
Views - separating program logic from output, how far do you go?
#4

[eluser]Mareshal[/eluser]
But keep in mind, if you use many subviews in a large project, this means <?php include()?>, and every include wastes memory Wink for small projects is nothing...

And if you want to know what a variable means in 1 year, try to make a small comment after it.

Code:
//create a new "whatever"
function tmt(int $r){ //$r = user ID from URL
    $drt = $this->aml($r); //clean the variable using aml()
    $return['srt'] = "action : ".$drt;
    $this->load->view('my_view', $return');
}

You can use those variable, but without my comments how much would you understand? even if you use long names, you will won't understand.


2nd question: I don't think you can load libraries/models/helpers from a view(last time I tried in 1.7.2 I couldn't, maybe I missed something), but in CI you have 3 possibilities to load them:
- using config/autoload.php and load them global
- in your constructor __construct() and make them available only for your class
- in the function that renders the view, and make them available only for your method.


Messages In This Thread
Views - separating program logic from output, how far do you go? - by El Forum - 03-16-2010, 09:56 AM



Theme © iAndrew 2016 - Forum software by © MyBB