Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Data to View #94

Closed
mj4444ru opened this issue Oct 12, 2020 · 6 comments
Closed

Add Data to View #94

mj4444ru opened this issue Oct 12, 2020 · 6 comments

Comments

@mj4444ru
Copy link
Contributor

There are very few setData and getData functions in place of params like in yii2. In addition to string data (getBlock and setBlock), you need to store data in a free format (mainly for layout).

@samdark
Copy link
Member

samdark commented Oct 12, 2020

It's already there (named differently): https://github.com/yiisoft/view/blob/master/src/View.php#L51

@mj4444ru
Copy link
Contributor Author

This is not it. We need functionality so that the "view" can leave data for the "layout". The defaultParameters property does not give us such an opportunity.

@samdark
Copy link
Member

samdark commented Oct 12, 2020

I think it does.

@mj4444ru
Copy link
Contributor Author

Tell me how to do something like this?
https://github.com/yiisoft/yii2-app-basic/blob/b50d3e1dfe73985fb84b54a61a18eb74bb60b1fa/views/site/contact.php#L12

This is just an example.

@samdark
Copy link
Member

samdark commented Oct 13, 2020

Same way:

$this->defaultParameters['breadcrumbs'][] = $this->title; 

@mj4444ru
Copy link
Contributor Author

mj4444ru commented Oct 13, 2020

$this->blablabla['breadcrumbs'][] = $this->getTitle();

Works too.

The defaultParameters property is private to the View and is not available in the template context.
When assigning defaultParameters, a new public property is created. We can create any public properties, but this is probably not good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants