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.

[resolved]How to manage an object query by Pages::findFirstById($id);

        #PagesController code#
          $page = Pages::findFirstById($id);
            if (!$page) {
                $this->flash->error("Page was not found.");
                return $this->forward("pages/index");

        **// how to assign $page to volt templat and how manage the $page in volt template.**

        #volt template code #

        Thanks for your help.

edited May '16

> controller code: $this->view->page = $page;

> volt template code: <article> <h3>{{ page.title }}</h3> <p>{{ page.ctime}}</p> <div>{{ page.body }}</div> </article>


did you try with this document ?

use for loop to access data in array variable


In controller:

        'page' = $page,

In volt

{{ page }}  #object

{{ }}       # access id property of page (prints it)