D Ramirez
D Ramirez

Reputation: 49

Displaying widget inside widget

I am using a widget (products-accordion) which contains only strings and images inside another widget (other-accordion) in Apostrophe cms as follows:

 ...
         {
           name: 'kitProducts',
           label: 'Products',
           type: 'singleton',
           widgetType: 'products-accordion'
        },
        ...

when I create the other-accordion as user it works fine by opening a second modal to populate 'products-accordion'. However, when I save and 'other-widget' needs to be displayed, 'products-accordion' widget doesn't get displayed properly. It displays: [Object][Object]

Data is saved and is visible on 'other-widget' modal when open to be edited.

Not really sure if Joins is the way to go, either how I can loop through it or get it displayed following its own widget.html and always.less.

Thanks!

Upvotes: 0

Views: 198

Answers (1)

Stuart Romanek
Stuart Romanek

Reputation: 2157

What does your widget.html look like in your outer widget?

You should be able to render the entire inner singleton in your outer widget by calling:

{{ apos.singleton(data.widget, '<singleton-name>', '<widget-name>') }}

Log out the inner singleton from the outer widget template by doing something like

{{ apos.log(data.widget.<singleton-name>) }}

to make sure you're on the right track

Upvotes: 1

Related Questions