marco_ber
(Bertagnin)
June 15, 2016, 2:06pm
1
Hi all,
I need help about a question which I have proposed some day ago in Stack Overflow forum, at the moment I’ve no receive answers hope someone here will help me.
I’ve a controller with 3 actions for a simple procedure in 3 steps, my idea is to have breadcrumbs like
Home page / Step1 / Step2 / Step3
each view have
$this->params['breadcrumbs'][] = 'StepX';
and the layout/main.php
Breadcrumbs::widget([
'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [],
])
However in every view the breadcrumbs are respectively for Step1, Step2 and Step3
Home page / Step1
Home page / Step2
Home page / Step3
Can anyone help me?
Thanks
patrickm
(Yiiframework)
June 15, 2016, 2:43pm
2
If you want more breadcrumbs, you have to add more:
$this->params['breadcrumbs'][] = 'Step 1';
$this->params['breadcrumbs'][] = 'Step 2';
$this->params['breadcrumbs'][] = 'Step 3';
marco_ber
(Bertagnin)
June 15, 2016, 3:08pm
3
Ok, but the view’s params isn’t shared among the view template?
From the documentation
patrickm
(Yiiframework)
June 15, 2016, 4:08pm
4
They are only shared between views in one action/request. Once you start a new action, the params are "reset".
marco_ber
(Bertagnin)
June 16, 2016, 6:08am
5
Now everything is clear, then, for share between distinct views, the only way is using session, right?
patrickm
(Yiiframework)
June 16, 2016, 8:12am
6
Try to think in terms of requests or actions, not views. And yes, sessions allow you to share data between them.