Pass multiple variables to view
-
13-01-2021 - |
Вопрос
We can pass a variable to a .phtml view file like this:
$currentTime = date("H:i", time());
$someValue = 123;
$this->loadLayout();
$this->getLayout()
->getBlock('newsletter_popup')
->assign('currentTime', $currentTime);
$this->renderLayout();
But how to pass multiple variables?
How can I pass $someValue
too?
In Laravel it works like this:
return $view->with('currentTime', $currentTime)->with('someValue', $someValue);
Does it work like this in magento too?
Решение
$array = array();
$array['currentTime'] = date("H:i", time());
$array['someValue'] = 123;
$this->loadLayout();
$this->getLayout()
->getBlock('newsletter_popup')
->assign('array', $array);
$this->renderLayout();
Не связан с magento.stackexchange