Using placeholder as variables

Referring to the documentiaon here
I am trying to use this snippet

{% put activeNav = 'home' %}

not with a string but with an array object like this in my pages

{% put pageTitles = {
      '0':  trans("Dashboard") ,
      '1':  trans("Products") ,
      '2':  product.name ,
    }
%}

so far so good, no error.

then inside the layout, I am trying to get the placeholder value like this

{% set breadcrumbs = placeholder('pageTitles') %}

And the page raises an exception

An exception has been thrown during the rendering of a template ("Array to string conversion").

is there another way to pass an object from the page to the layout other then using a placeholder ?

Yes, you’re right; there’s no reason this shouldn’t be appropriate. The error is caused mainly by the assumption that it will store content (a string). You know what they say about assumptions!

A fix has been included here:

1 Like