phalcon/assets/inline error or exception

I am learning now and found that when i do this (my code doesn't look good i assume)

$this->assets->addInlineCodeByType(new \Phalcon\Assets\Inline("test", '<h1>a1</h1>'), 'js')

i get error:

Catchable fatal error: Argument 2 passed to Phalcon\Assets\Manager::addInlineCodeByType() must be an instance of Phalcon\Assets\Inline, string given in

But with this (it's ridicolous i know)

$this->assets->addInlineCodeByType(new \Phalcon\Assets\Inline("test", '<h1>a1</h1>'), new \Phalcon\Assets\Inline("test", '<h1>a1</h1>'))

i get:


i guess Parameter 'type' must be a string


addInlineCodeByType (unknown $type, unknown $code)

Edited: wrong title of this topic i see.

Are you using test for the real code?

I think it only accepts js or css:

edited Sep '15

Thank you for your reply Lajos. Finally i found a good starting point for non js / css assets (i am at the beginning) and have dillemma over another approach in less framework way using macros. The underlaying thing is trying not to load another classess but to use pure framework. So the starting more acceptable way: backend:

$this->assets->addInlineCodeByType('aaa', new \Phalcon\Assets\Inline('test', 'some text html <b>asdf</b>'));

in volt

{{assets.outputInline(assets.collection('aaa'), 'js')}}

another approach for pseudo assets (html snippets/ boxes) (not polished yet) backend in controller base file: ```php protected function addHtml($name="default", $html, $subposition=10, $priority=100) {

    if ($name===null) $name="default";

    if (!isset($this->htmlassets[$name])) $this->htmlassets[$name]=array();
    if (!isset($this->htmlassets[$name][$subposition])) $this->htmlassets[$name][$subposition] = array();
    if (!isset($this->htmlassets[$name][$subposition][$priority])) $this->htmlassets[$name][$subposition][$priority] = array();

    /*echo "<pre>";
    echo "</pre>";

then volt macro:

php {%- macro boxes(params) %}a {# for cache purposes all data should be easily serializable params unnamed [0,1,2,3] 1. name - boxes by name 2. items array[boxnameorid] = array of subpositions array[int boxnameorid][1] (10 should be default) where in each position array of items or array of items rendered in a tree order (site has a parent with inherited boxes) already sorted out according to their priority.

  1. optional mode - "edit"
  2. optional style_id - basically in what each element it is wrapped
  3. optional ["t"]: translation object (for example for edit interface)


{% for positionid, subpositionarray in params[1][params[0]]|sort %} <div>{{positionid}} {% for priority, priorityarray in subpositionarray|sort %} <div>{{priority}} {% for html in priorityarray %} <div>{{html}}</div> {% endfor %} </div>
{% endfor %} </div>
{% endfor %}

{%- endmacro %}

then in template/layout

php {{boxes(["default", htmlassets, frontendedit, t])}} ```

then domewhere in the backend ```php $this->addHtml(null, "one html", 10, 100); $this->addHtml(null, "two html"); $this->addHtml(null, "third html", 10, 10); $this->addHtml('default', "forth html", 5, 100); $this->addHtml("header", "fifth header html");


edited Sep '15

Some thing are not correctly written there but seem to work. And to explain more. All of this is to load html snippets like the css, js assets counterparts - more or less, to develop my little system for loading boxes into positions/places whatever correct name for it is. My recent post/posts are related somehow to it.

macro approach: you would have printing 'collection' by its name, by its subposition less is higher on a page, finally priority integer less is higher on a page. Simple and it works!