Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Assign data from view to layout

Hi, I want to send data from view to layoout, how can I do this ?



that makes no sence ?

but your view data is available in your layouts as well as in your views

edited 15d ago

Instead of MVC architecture, you might want to revert back to Spaghetti one.

Views represent the user interface of your application. Views are often HTML files with embedded PHP code that perform tasks related solely to the presentation of the data. Views handle the job of providing data to the web browser or other tool that is used to make requests from your application.

edited 15d ago

I've maked a breadcrumbs widget and I needed to send breadcrumbs data to layout.

I call one time the widget in layout, and every where I need to render this widget just set $breadcrumbs variable in my view.

My View:

$title = 'User List';

$breadcrumbs[] = ['label' => 'Users', 'url' => $this->url->get('user/index')];

$breadcrumbs[] = $title;

My Layout:

<?= \Multiple\Widget\Breadcrumb::widget([ 'items' => $breadcrumbs ?? [], ]) ?>


you can "borrow" some ideas from here


Is wrong my way ? I got this idea from Yii2 framework.

you can "borrow" some ideas from here


its fine I just gave it to you just in case you need someting else