Sorry, texnixe - and thanks for the quick reply.
I would like to be able to display featured blog articles and project items on the home page like can be seen on https://www.outpostvfx.co.uk/
-
For the news articles I want to output the title, intro, text and page href
-
For the project pages I just want to output the video snippet (iframe, title, page href)
On top of this I would like the user to be able to manually pick and administer the order (drag) the items on the home page panel (see screenshot),
Finally, these articles and video snippets will be wrapped in packery.js grid items.
Unfortunately, i’m more of a web designer than programmer so I’m sure I’m going about things the wrong way and spent hours yesterday trying to work out how to do this and have come up with nothing. I managed to fetch all the children going about things this way:
featuredcontent:
label: Choose featured work to show on the home page
type: checkboxes
options: query
columns: 3
default: snippet
query:
page: news-and-reviews
fetch: children
text: '{{title}}'
value: '{{uri}}'
And this is the code I used to output it.
<ul>
<?php foreach($page->featuredcontent()->split() as $category): ?>
<li><?php echo html($category) ?></li>
<?php endforeach ?>
</ul>
which returns:
- newsandreviews: "" work: work/jason-bourne contenttype: "2" - contenttype: "1" newsandreviews: news-and-reviews/47-meters-down work: "" - newsandreviews: news-and-reviews/studio-expansion work: "" contenttype: "1" - contenttype: "2" newsandreviews: "" work: work/orange-is-the-new-black
I can’t remember how but eventually, I managed to output all work items and all news items in one big array.
Finally, I tried to output it later on like this - below is the yaml in my home.yml file which shows what I’m trying to achieve.
featuredcontent:
label: Featured content
type: structure
style: table
fields:
contenttype:
label: Content type
type: radio
default: 1
options:
1: News excerpt
2: Video snippet
newsandreviews:
label: News and Reviews
type: select
options: query
query:
page: news-and-reviews
fetch: children
value: '{{id}}'
work:
label: Work
type: select
options: query
query:
page: work
fetch: children
value: '{{id}}'
and the code to output it…
<ul class="grid o-grid">
<?php foreach($page->featuredcontent()->toStructure() as $featureditem): ?>
<?php
if ($featureditem->contenttype() == '1'): { ?>
<?php foreach($featureditem as $featuredcontent => $article): ?>
<li class="grid-item grid-item--width1 o-grid-item small">
<div class="content-wrapper"><h3 class="article-title"><?php echo $article->title()->html() ?></h3>
<p class="article-date">Posted on <?php echo $article->date('d.m.Y') ?></p>
<p><?php echo $article->intro()->kirbytext() ?></p>
<p><?php echo $article->text()->excerpt(30, 'words') ?></p>
<a href="<?php echo $article->url() ?>">News & Reviews</a>
</div>
</li>
<?php endforeach ?>
<?php } else: { ?>
<?php foreach($featureditem as $featuredcontent => $project): ?>
<li class="grid-item grid-item--width2 o-grid-item large">
<div class="video-wrapper">
<iframe class="product-card-media" type="text/html" src="<?php echo $project->url() ?>" id="player " width="800" height="450" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
</div>
<div class="description"><h3><?php echo $project->title() ?></h3><a href="<?php echo $project->url() ?>">Work</a></div>
</li>
<?php endforeach ?>
<?php }
endif ?>
<?php endforeach; ?>
</ul>
This renders the content on to the homepage, but it duplicates everything two or three times and fragments it. I’m looking for help crafting the right solution if you or anyone can help please.
Are you able to elaborate on how to achieve the above using the JSON API and how to store the URI?
Many thanks.
Aaron