Chapter 2. Creating a Simple News Reader
This chapter explains how to write your first controller in order to display news items list and details, make interactions between controllers and views, and then customize the view's layout.
In this chapter, we will go through the following:
- Creating controller and action
- Creating a view to display the news list
- How the controller sends the data to view
- Example – create a controller to display the static news items list and details
- Split the common view content into reusable views
- Example – render partial in view
- Creating static pages
- Share data between views and layout
- Example – change layout background based on the URL parameter
- Layout with dynamic blocks
- Example – add dynamic box to display advertising info
- Using ...
Get Yii2 By Example now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.