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.

VOLT

I wish to pass multiple variables for different page parts to a volt template. Being new to this, I want to make sure I handle it the preferred way.

Some example page elements:

page header (title)

body text (story)

media image (image_1)

some other element (misc_1)

Some may be able to be grouped by a query (ex: tltle/story), but others are not directly related via a query result set.

What is the best approach to this?

Many thanks!



8.1k
Accepted
answer
edited Jul '15

in your controller: $this->view->myVar = $myVar, then in in volt file, then you can access them like {{ myVar }}

if $myVar is i.e. an associative array {{ myVar.keyName }} (I suppose it's what you mean when you say 'grouped by a query', not sure...

about image, you do not pass the image as it, but rather an url pointing to it (a string so)

Thank you! It amazes me how much Phalcon is like something I was tinkering with in PHP over the past year. Love Phalcon!!