Вопрос

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();
Лицензировано под: CC-BY-SA с атрибуция
Не связан с magento.stackexchange
scroll top