Hi!!
So far I have only worked with repeater and everything was fine. But in the widget that I’m creating, I have a repeater inside another repeater and I can’t show the content on my website.
To be able to call the elements in the template, I write this function
function get_template_variables($instance) {
$vars = [];
$vars[‘items’] = $instance[‘section_items’][‘items’];
return $vars;
}
And in my template, I call them like this:
But in this case, since it is a repeater inside another, it does not show them to me. Do you have an example created?
Sorry, I forgot to add this
I think you have a bug when we try to create a repeater inside another repeater.
I have tried another option. I have tried to include widget within a repiter, but when the widget that I use has a repeater inside, it doesn’t work. If it doesn’t have repeater, it works fine.
Hi Laguillen,
Can you please provide me with a copy of your complete widget code so I can take a look over it?
The SiteOrigin Hero widget has two repeaters within the main repeater – the background video and Button (which is the complete button widget). You can find its code here.
Finally, the widget in the second repeater is already displayed on the back.
I have seen the example of the hero, but it is quite messy, especially because it contains many functions that I do not know exactly what they do.
What I would miss now, is to display in the template.php the items that are in the widget that I have included in the second repeater.
If I do a “”var_dump” of my widget, the data that brings me are these:
array(1) { [0]=> array(1) { [“button”]=> array(2) { [“section_bg”]=> array(5) { [“image_url”]=> int(616) [“image_url_fallback”]=> string(0) “” [“so_field_container_state”]=> string(4) “open” [“bg_type”]=> string(5) “image” [“veil”]=> bool(false) } [“section_text”]=> array(2) { [“claim”]=> string(15) “TEXTO DE PRUEBA” [“so_field_container_state”]=> string(4) “open” } } } }
What I need is to know how to show this data in my template.
Hi Laguillen,
You’ll need to iterate the repeater array. The template code you included in your reply assumes that we do this automatically which isn’t the case as not all widgets use repeater fields. You’ll need to set up the loop manually.