Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Cannot display data

use Phalcon\Mvc\Controller,
    Phalcon\Tag as Tag,
    Phalcon\Mvc\Model,
    Phalcon\Mvc\Model\Resultset,
    Phalcon\Mvc\Dispatcher;

class IndexController extends ControllerBase
{
    public function initialize(){
         $robots = Person::find();

        foreach ($robots as $robot) {
            echo $robot->fname;
        }
    }
}


34.8k

Hey

Why do you very small information ?



30.0k

imho, initialize() should not be used for displaying data !

edited Oct '14

@Duy Thiện, i only want to try first to display small data to test if the code works, but its not working, thats why.

@le51, so u mean i should create a new method that will show the data? what i want to do is i want to display all the data on the index page

i tried

 public function indexAction(){
         $robots = Person::find();

        foreach ($robots as $robot) {
            echo $robot->fname;
        }
    }


83.5k
Accepted
answer

Did you add {{ content() }}/<?php $this->getContent() ?> to your view?

edited Oct '14

@Phalcon,

on my main index.php to where all view are loaded i have

<body>{{ content() }}</body>

do I have to use again

``´ {{ content() }} ```

in my view / index / index.volt??



83.5k

yes, content() must be placed in every view of the view hierarchy