O'Reilly logo

Yii2 By Example by Fabrizio Caldarelli

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required