Re:Kirby is a file-based CMS
by GoodbyeEarl on Sunday February 19, 2017 @09:13PM
(#13683711)
Hey, folks! I've read the whole there but I couldn't figure out how to deal with some dynamic content. Let me expose what I mean: I have a blog. I want to create posts. So I'd write my blog post and publish (write my blog post to disc as a static file). How could I instantly see the new blog post in my home page?
[ Parent
| on HN ]
Re:Kirby is a file-based CMS
by pedroborges on Sunday February 19, 2017 @10:13PM
(#13683968)
When you write a blog post, it creates a text file (metadata & content) in the /content folder, not an HTML file.
Take a look at the Starter Kit (it's the best way to try Kirby): https://github.com/getkirby/starterkit
Look inside the /content and /site/templates folders.
Re:Kirby is a file-based CMS
by GoodbyeEarl on Monday February 20, 2017 @07:46AM
(#13686773)
Thanks man! But how do I loop through this content? ie How can I write a small widget with all the recent posts?
Re:Kirby is a file-based CMS
by pedroborges on Monday February 20, 2017 @09:04AM
(#13687275)
You can do whatever you want on your templates. If by widget you mean reusable code, you could use a snippet.
So this logic can go on a template or snippet:
<?php $latest = page('blog')->children()->visible()->limit(6); ?>
<div class="widget">
<?php foreach($latest as $post) : ?>
<a href="<?= $post->url()?>"><h2><?= $post->title()->html() ?></h2></a>
<?php endforeach ?>
</div>
Instead of fetching the post on the template, you could use a controller and just pass the $latest variable to the template.
Re:Kirby is a file-based CMS
by pedroborges on Monday February 20, 2017 @09:09AM
(#13687316)
Kirby doesn't output any markup, you have total control to over it :D The API for querying content is very powerful.