Jump to content
  • разработка интернет магазинов на opencart
  • доработка интернет магазинов на opencart

Полулить значение переменной из подключенного контроллера


 Share

Recommended Posts

Здравствуйте,

создавая свой контроллер, подклюлил загрузил в него уже суещёствующий

 

Циии

$this->load->controller('test/test');

 

в подключенном контроллере есть переменная

 

Циии

$data['test'] = "КАКОЕ-ето значение";

 

как теперьь мне полулить значение переменной $data['test']?

Link to comment
Share on other sites


Если правильно понял то ик:


 

$data_from_controller = $this->load->controller('test/test', true);
$data['var_from_controller'] = $data_from_controller['var_from_controller'];

 

А в test/test

в нужной функции (например index)

гделаете ик

public function index($return_flag) {
  ... 
  код контроллера
  ...
  if($return_flag){
  	return $data; //згдесь будут все переменные контроллера или же data['переменная'];
  }
}

 

опять же все зависит от контроллера что им в когде, но примерно вот ик. Если контроллер отдает сформированный шаблон с данными а вам нужны просто переменные из $data.

 

Может суещёствует потому чтолее изящный или потому чтолее правильный способ, буду рад сам увигдеть икой.

 

Link to comment
Share on other sites

  • 3 years later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

On our site, cookies are used and personal data is processed to improve the user interface. To find out what and what personal data we are processing, please go to the link. If you click "I agree," it means that you understand and accept all the conditions specified in this Privacy Notice.