I think it is a simple task but i get it wrong.
I try to get the image Url from a Structuredfield in a Snipper: My Code looks like this:
The Snippet looks like this (recommendations_new.php):
<?php foreach ($page->recomend_pages()->yaml() as $feat): ?>
<img src="<?= $feat['picture'] ?>" />
<h4>
<?= $feat['name'] ?>
</h4>
<p class="description">
<?= $feat['description'] ?>
</p>
<a href="<?= $feat['link'] ?>" ><?= $feat['button'] ?></a>
<?php endforeach ?>
The Blueprint looks like this:
title: Home
tabs:
content:
label: Inhalt
icon: document
preset: page
fields:
title:
label: Titel
type: text
heading_banner:
label: Titelbild
type: files
heading_info:
label: Textinfo Header
type: textarea
recomend_pages:
label: Teaser Links
type: structure
limit: 3
entry: >
{{name}}
fields:
name:
label: Name
type: text
required: true
description:
label: Beschreibung
type: textarea
picture:
label: Bild
type: files
required: true
link:
label: Url
type: url
required: true
button:
label: Button text
type: text
default: mehr erfahren »
The Template:
<?php snippet('header') ?>
<section class="uk-section">
<div class="uk-container">
<div class="uk-width-1-1">
<?php
$banner = $page->heading_banner()->toFile();
if ($banner):?>
<img src="<?= $banner->url() ?>" alt="<?= $banner->name() ?>" style="width:100%;">
<?php endif ?>
</div>
<div class="tw-element uk-text-center tw-heading">
<?= $page->heading_info()->kirbytext() ?>
</div>
<?php snippet('blog') ?>
<?php snippet('recommendations_new') ?>
</div>
</section>
<div style="margin: 36px 0px 0px 0px; background: #004367; text-align: center; padding: 72px 48px;">
<h3 style=" color:#fff; letter-spacing: 0.1em;">
<?= $site->footer_info_text()->kirbytext() ?>
</h3>
</div>
<?php snippet('footer') ?>
The Problem is with $feat[‘picture’] it gives me the word array in the frontend…
Any hints really appreciated.