Welcome Guest, Not a member yet? Register   Sign In
Help: How i show variables from different functions on the same view?
#4

[eluser]jedd[/eluser]
You could do it this way:
Code:
class Site extends Controller {   // Fixed case of class name

    function __construct()  {
       parent::Controller();

       $this->data = array(
                      'common_item' => 'common string here',
                      );
    }

// In your other methods you could merge_array() with a new construct, overwriting common bits,
// adding other bits, etc.  Obviously you would then pass $this->data to your views.

Note that menu_name does exist in both functions, but has a different value in both functions, so I'm not sure how you can cut down on the number of times you define that variable.


You might also want to hit the [url="/wiki/FAQ"]FAQ[/url], hit the commonly asked question 'I'm repeating lots of bits of code, is there anyway around that?' and then follow the link to my rant. Also accessible from the [url="/wiki"]main wiki[/url] front page if you follow the Approaches yellow brick path. It sounds like what you're trying to do is covered, at least in part, by that.


Messages In This Thread
Help: How i show variables from different functions on the same view? - by El Forum - 11-27-2009, 04:00 PM



Theme © iAndrew 2016 - Forum software by © MyBB