iam currently working on my first Kirby Projekt and can´t finde a good solution how to link images
to some pages, as a teaser. So that it is easy to change the link to a other page. Any Solutions or help with that?
Thats a cool feature The only thing i don´t check, how i will grab the the data?
Can the client make as much teaser as he want or can i define a limit if maybe 4 Teaser? Sorry…for my question but iAM a Designer with just some little Code Skillz .
I don’t think you can limit the number of entries a user can generate but you could limit the number that is output in your template (and maybe tell the user in a help field that he/she should not enter more than 4 entries. You can then grab the data either with the yaml() method or better, with the new toStructure() method. Let’s suppose your field was called teasers:
THX! How can i grab a specific data? I have now create 4 Fields. Can i insert images their? I need to grab a image, a text and link, but i don´t know how i can grab that
The way I would probably do it (however, not knowing the structure of your page, this is a bit guesswork)
blueprint:
fields:
teasers:
label: Teasers
type: structure
fields:
image:
label: Image
type: select
options: images
text:
label: Text
type: text
link:
label: Link
type: select
options: query
query:
page: teasers
fetch: children
text: '{{title}}'
value: '{{uid}}'
-template (not tested) and without all the ifs …
$teasers = $page->teasers()->toStructure();
foreach($teasers as $teaser) :
$linkPage = page('teaser')->children()->find($teaser->link());
$image = $teaser->image();
$text = $teaser->text();
?>
<a href="<?php echo $linkPage->url()"><image src="<?php echo $image->url() ?>"></a>
// and then do sth. with the text as well ...
<?php endforeach ?>