Probably most applications have a scenario where you have to display either zero items or one or more items. A blog, for example, can contain posts or no posts. If there are no posts, you may want to inform the visitor when the blog will start. In the other case you simply show the posts. As you see, what is shown depends on the number of posts (resp. the number of items).

This leads to the question: Where do you decide what is shown? In the controller or in the view?

One could argument that we have two different views, and so the controller has to decide which view to use. In this case the code would look like:

// posts_controller.php
function index() {
    $posts = $this->Post->findAll();

    if (!empty($posts)) {
        $this->set('posts', $posts);
    } else {
        $this->render('no_posts');
    }
}

// posts/index.ctp
foreach($posts as $post) {
    echo $post['Post']['title'];
}

// posts/no_posts.ctp
Sorry, no posts yet.

On the other hand one could argument that the view should decide itself how it will react if there is no data provided. Then the code looks like:

// posts_controller.php
function index() {
    $this->set('posts', $this->Post->findAll(););
}

// posts/index.ctp
if (!empty($posts)) {
    foreach($posts as $post) {
        echo $post['Post']['title'];
    }
} else {
    echo “Sorry, no posts yet.”;
}

I don’t know which approach is “better”, personally I tend to the first approach where the logic is in the controller.