Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


How to pass parameters from controller to layout in yii2?



How to pass parameters from controller to layout in yii2?..

Answer / Mohammad Ayub

In Yii2, you can pass parameters from a controller to a layout by defining them as properties of the view and then accessing them within the layout. Here's an example:

```php
// In your controller:
public function actionIndex() {
$this->view->title = 'My Title';

return $this->render('index', []);
}

// In your layout file:
<?php echo Yii::$app->controller->action->title; ?>
```

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Yii PHP Framework Interview Questions

How we can remove index.php from url in yii?

1 Answers  


How to generate crud code?

1 Answers  


What are the server requirements to install yii 2.0 framework?

1 Answers  


What is name of first file the loaded when yii 2.0 framework starts?

1 Answers  


How can we set a flash message in yii2?

1 Answers  


List out some database related functions in yii?

1 Answers  


Why yii framework is faster?

1 Answers  


What is gii? Why it is used?

1 Answers  


What is the purpose of “gii” in yii2?

1 Answers  


Explain the yii versions?

1 Answers  


List some database related functions in yii 2 framework?

1 Answers  


How to get current controller id in yii ?

1 Answers  


Categories