Modular Extensions / public $... - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22) +--- Thread: Modular Extensions / public $... (/showthread.php?tid=12407) |
Modular Extensions / public $... - El Forum - 10-17-2008 [eluser]vagabond[/eluser] hi there are some basic rules i don't understand - honestly, there's a lot in php/oop i don't understand i hope you can help me. in this case ME is involved. default_controller Code: <?php if (!defined('BASEPATH')) exit('No direct script access allowed'); Code: <?php if (!defined('BASEPATH')) exit('No direct script access allowed'); results: Quote:some text ...and some more text$this->data passed to my_model another_controller (calls default_controller as module) Code: <?php if (!defined('BASEPATH')) exit('No direct script access allowed'); results: Quote:some text$this->data NOT passed to my_model. why is that? how can i make $this->data pass to a model when in a module? maybe it's just a bad idea? thank you. Modular Extensions / public $... - El Forum - 10-18-2008 [eluser]wiredesignz[/eluser] Hi vagabond, The reason $this->data is not passed to your module model is because CI uses the first controller instance from which to assign class variables to the model, regardless of where the model is loaded. In this case that is `Another_controller` and not Default_controller. Welcome to CI forums. Modular Extensions / public $... - El Forum - 10-19-2008 [eluser]vagabond[/eluser] Thank you wiredesignz. That means I cannot use public class variables within modules, right? Well, I could not make it happen whereever I declare "public $data". Seems logic now, even if I do not fully understand how things work. But now I'm having a lot more questions about how I am going to make my app work. Forget the above example, new situation, say, I want my modules only to modify a array in my normal controller instead of output a view. Does this break the purpose of the modules/CI? As I realized that it is not possible to return things from a module (because of a eval() environment? correct me), I did the following: Code: $serialized_data = module::run('my_module' $array); // my module echoes serialize($array); Not that elegant but it works. Maybe I missed something and there's a better way to do that or looking at those codelines makes you look like my avatar :ahhh: Let me know, thanks. Have a nice sunday Modular Extensions / public $... - El Forum - 12-01-2008 [eluser]vagabond[/eluser] [quote author="wiredesignz" date="1224410431"] The reason $this->data is not passed to your module model is because CI uses the first controller instance from which to assign class variables to the model, regardless of where the model is loaded. In this case that is `Another_controller` and not Default_controller.[/quote] ci functions like uri_string() (where $this->uri_string is declared) don't output anything in my module. is this related to the above? i'm not sure, maybe i did something else wrong - and uri_string() should usually work? thanks for your help. Modular Extensions / public $... - El Forum - 12-01-2008 [eluser]vagabond[/eluser] [quote author="vagabond" date="1228217550"]uri_string() (where $this->uri_string is declared)[/quote] i meant $this->uri->uri_string()... |