Hi! all ,
I’m looking for a little hand to achieve something like this :
I tried with a page builder, or the structure field, but either way i’m stuck at the same place which is how you nest the bookshops inside their respective city/country
Thanks in advance for any help, hint.
Happy holidays to all .
Here the codes used :
Usint a structure field and creating the cities as subpages :
-
Page
- subpage
- structure field
- subpage
- structure field
<div class="row"> <h1><?php echo ($city->title()) ?></h1> <?php $bookshops = $page->children(); $stores = new Structure(); $key = 0; foreach($bookshops as $p) { foreach($p->stores()->toStructure() as $item) { $stores->append($key, $item); $key++; } } foreach ($stores as $store): ?> <?php if ($store->picture()->isNotEmpty() && $image = $page->image( $store->picture() )): ?> <img src="<?php echo thumb($image, array('width' => 80,'quality' => 80, 'crop' => true ))->url(); ?>"> <?php endif ?> <?php echo $store->bookshopName()->kt() ?> <?php echo $store->bookshopAdresse() ?> <?php echo $store->bookshopurl() ?> <?php endforeach ?> </div> <?php endforeach ?>
- subpage
Using the pagebuilder field :
template
<?php foreach($page->builder()->toStructure() as $section): ?>
<?php snippet('builder/' . $section->_fieldset(), array('data' => $section)) ?>
<?php snippet('builder/bookshops/' . $section->_fieldset(), array('data' => $section)) ?>
<?php endforeach ?>
builder/cityname
<div class='city'>
<?php echo $data->cities()->kt() ?>
</div>
builder/bookshops/bookshops
<div class="shop-wrap">
<?php if ($data->picture()->isNotEmpty() && $image = $page->image( $data->picture() )): ?>
<img src="<?= $image->url() ?>">
<?php endif ?>
<div>
<a href="<?= $data->bookshopurl() ?>"><?= $data->bookshopName() ?></a>
<p ><?= $data->bookshopAdresse() ?></p>
</div>
</div>