PAGEBUILDER - repeater simple

PHOTO EMBED

Thu Apr 01 2021 09:48:58 GMT+0000 (UTC)

Saved by @Sikor

return array(
	'accordion' => array(
	    'type' => 'repeater',
	    'label' => __( 'A repeating repeater.' , 'engine' ),
	    'item_name'  => __( 'Repeater item', 'engine' ),
	    'item_label' => array(
	        'selector'     => "[id*='repeat_text']",
	        'update_event' => 'change',
	        'value_method' => 'val',
	    ),
	    'fields' => array(
	        'title' => array(
	            'type' => 'text',
	            'label' => __( 'Title', 'engine' ),
	        ),
			'text' => array(
	            'type' => 'tinymce',
	            'label' => __( 'Text', 'engine' ),
				'rows' => 3,
	        )
	    ),
	)
);

          
// tpl.php - accordion BS4
<section class="<?php echo $name_widget; ?>">
    <div class="container">
		<?php if(sizeof((array)$accordion) > 0 && !empty($accordion)) { ?>
			<?php $key == 1; ?>

			<div class="accordion-wrapper" id="accordion">
				<?php foreach ($accordion as $key => $value) {
					$key++;
					if ($key == 1) {
						$show = 'show';
						$expanded = 'true';
					}
					else {
						$show = '';
						$expanded = 'false';
					}
				?>
					<div class="card">
						<div class="card-header">
							<h5 class="mb-0">
								<button class="btn btn-link" data-toggle="collapse" data-target="#collapse_<?php echo $info.'_'.$key; ?>" aria-expanded="<?php echo $expanded; ?>" aria-controls="collapse_<?php echo $info.'_'.$key; ?>">
									<?php echo $value['title']; ?>
								</button>
							</h5>
						</div>
						<div id="collapse_<?php echo $info.'_'.$key; ?>" class="collapse <?php echo $show; ?>" aria-labelledby="headingOne" data-parent="#accordion">
							<div class="card-body">
								<?php echo $value['text']; ?>
							</div>
						</div>
					</div>
				<?php
					}
				?>
			</div>
		<?php } ?>
    </div>
</section>

// accordion simple - variable set to TRUE and after first loop reset to FALSE
<?php
if (sizeof((array)$accordion) > 0 && !empty($accordion)) {
	$expanded = 'true';
	$show = 'show';
	$active = 'active';
	foreach ($accordion as $k => $v) {
?>
		<div class="card" id="card-<?php echo $idshort; ?>-<?php echo $k; ?>">
          // content
		</div>
<?php
      $expanded = 'false';
      $show = $active = '';
	}
}
?>
content_copyCOPY