The task is to transfer the value from the template. I made my function in the controller which calls the model method that makes an entry to the database and returns it back from the database (Controller):

function translateYandex($text){ $this->model_query_query->getTranslate($text) } 

Call from view:

 translateYandex('text'); 

I get the error:

 Fatal error: Using $this when not in object context in 

question how to pass the task without getting an error.

  • You call a function that does not belong to any class. However, you are trying to access some instance of the class in the body of this function. Move a function to a class or pass a reference to an instance of the class into it. - Pyramidhead
  • Yes, if I move a function to a class, then everything is ok, then the problem will be different, I can no longer call translateYandex('text'); From .tpl in opencart I understand the rules mvc can not touch the model in view - newProgrammer
  • Yes, according to mvc, the controller should be responsible for the model and view communication. He can already directly refer to the model. - Pyramidhead
  • Important does not prevent the Ajax from the view from pulling any method of any class in any controller, right? - Kirill Korushkin
  • It is necessary to do everything when generating pages. - newProgrammer

0