I have set up a ‘news’ section following the Creating a Kirby-powered blog in your cookbook section and want to be able to use the kiby panel to add news articles. I have set up the blueprints as per the blueprint samples. The only thing that is different is that instead of using blog and article I am using news and article. In the panel section under news, I just see Column (1/1) and No sections yet. How do I get this to show the correct layout to add news articles?
Thanks
Ok, so now you have a /site/blueprints/pages/news.yml
for the parent page and an /site/blueprints/pages/article.yml
for the single article, right?
And have you also created the /site/blueprints/sections/articles.yml
file as in this example Blog | Kirby CMS
texnixe,
I have /site/blueprints/pages/news.yml
for the parent page and /site/blueprints/article.yml
for the single article not ‘pagesarticle’. The template sections are called news.php and article.php. Blueprint sections are called article.yml and news.yml and the content section is called news with article.text
Yes I have created /site/blueprints/sections/articles.yml
This should be /site/blueprints/pages/article.yml
, i.e. in the pages folder, just missed the slash in my post above.
It is in /site/blueprints/pages/article.yml
Could you post a screenshot of what you actually see in the Panel now? I’m not really following with all these sections…
Did you copy those blueprints exactly as they are without any changes? Maybe post them here for comparison (as code)
Screenshot and code
pages.article.yml
title: Article
num: '{{ page.date.toDate("Ymd") }}'
icon: 📖
status:
draft:
label: Draft
text: The article is still in draft mode. It can only be seen by editors with panel access.
unlisted:
label: In Review
text: The article is online and can be visited with the direct URL. The team must still give the final go to publish it.
listed:
label: Published
text: The article is online and listed in the blog
columns:
main:
- width: 2/3
fields:
headline:
label: Headline
type: text
text:
label: Text
type: textarea
size: large
sidebar:
- width: 1/3
sections:
meta:
type: fields
fields:
date:
type: date
time: true
default: now
files:
label:select files...
type: files
layout:list
image:
cover:true
template: blocks/image
pages.news.yml
title: News
icon: 📚
columns:
left:
width: 1/2
sections:
drafts:
extends: sections/articles
headline: Drafts
status: draft
unlisted:
extends: sections/articles
headline: In Review
status: unlisted
right:
width: 1/2
sections:
listed:
extends: sections/articles
headline: Published
status: listed
sections.articles.yml
type: pages
headline: Articles
info: "{{ page.date.toDate('d.m.Y') }}"
template: article
empty: No articles yet
sortBy: date desc
There seems to be something wrong with your filename. Why do you prepend sections./pages.
to the filenames?
Ignore that, it is correct. It was just a way of separating the words.
Check if you blog page in the content folder is called news.txt, if not, rename it.
Just noticed that your indentation seems to be wrong, you news.yml blueprint should look like this:
title: News
icon: 📚
columns:
left:
width: 1/2
sections:
drafts:
extends: sections/articles
headline: Drafts
status: draft
unlisted:
extends: sections/articles
headline: In Review
status: unlisted
right:
width: 1/2
sections:
listed:
extends: sections/articles
headline: Published
status: listed
Also make sure to use only spaces, no tabs to indent levels.
That fixed it using spaces and not tabs! Thanks.
One other thing that is not showing is the date for the article. I have the following as the code that I am using.
<time datetime="<?= $page->published()->toDate('c') ?>" pubdate="pubdate">
<?= $page->published()->toDate('d F Y') ?>
</time>
In your article.yml
your date field is called date
not published
, so the code should be:
<time datetime="<?= $page->date()->toDate('c') ?>" pubdate="pubdate">
<?= $page->date()->toDate('d F Y') ?>
</time>
Thanks texnixe. One last question, can you show the date on both the article and news pages?
Thanks
Yes, of course. When you loop the your articles on the news overview page, you have access to the full page object, including all the fields.
<?php foreach ($page->children()->listed() as $article) {
echo $article->title();
echo $article-date()->toDate('d F Y');
// etc.
}
?>