Reusing views with partials
Yii supports partials, so if you have a block without much logic that you want to reuse or want to implement e-mail templates, partials are the right way to go about this.
Imagine that we have two Twitter accounts, one for our blog and another for company activity, and our goal is to output Twitter timelines on specified pages.
Getting ready
Create a new application using the Composer package manager, as described in the official guide at http://www.yiiframework.com/doc-2.0/guide-start-installation.html.
Create Twitter widgets at https://twitter.com/settings/widgets/ for
php_net
andyiiframework
users, and find adata-widget-id
value for each widget created.
How to do it…
Create a controller,
@app/controllers/BlogController.php
, as follows:<?php namespace app\controllers; use yii\web\Controller; class BlogController extends Controller { public function actionIndex() { $posts = [ [ 'title' => 'First post', ...