Welcome Guest, Not a member yet? Register   Sign In
Pass a variable to an autoloaded library.
#4

[eluser]ramm[/eluser]
Well, i was thinking the same way it works for other libraries, let's say
Code:
//For a googlemaps lib i'm using
$this->load->library('googlemaps');
$config['center'] = 37.4419, -122.1419;
$config['zoom'] = 16;

$this->googlemaps->initialize($config);

//You can do the same here
$config['page_title'] = "Your title";

As in the library itself they have it like this:
Code:
class Googlemaps {
  var $center = "37.4419, -122.1419";
  var $zoom   = 13;
  //some others

  function Googlemaps($config = array())
  {
    if (count($config) > 0)
    {
       $this->initialize($config);
    }    
  }


  function initialize($config = array())
  {
    foreach ($config as $key => $val)
    {
      if (isset($this->$key))
      {
        $this->$key = $val;
      }
    }
  }

}


Messages In This Thread
Pass a variable to an autoloaded library. - by El Forum - 03-03-2011, 06:48 PM
Pass a variable to an autoloaded library. - by El Forum - 03-03-2011, 07:48 PM
Pass a variable to an autoloaded library. - by El Forum - 03-04-2011, 10:35 AM
Pass a variable to an autoloaded library. - by El Forum - 03-04-2011, 11:18 AM



Theme © iAndrew 2016 - Forum software by © MyBB