Skip to content

Instantly share code, notes, and snippets.

View starckio's full-sized avatar
🍼
Baby boy !

Christopher Boutillé starckio

🍼
Baby boy !
View GitHub Profile
<?php $n=0; foreach($page->children()->visible()->flip() as $article): $n++; ?>
<?php if($n==1): ?>
<!-- html for your first article -->
<?php else: ?>
<!-- html for all the other articles -->
<?php endif ?>
<?php endforeach ?>
<?php $zeiten = page('oeffnungszeiten') ?>
<?php if($zeiten->status() == 'normal'): ?>
<!-- hier werden die öffnungszeiten abhängig vom tag angezeigt -->
<?php else if($zeiten->status() == 'open'): ?>
<!-- hier wird einfach nur angezeigt dass geöffnet ist -->
<?php else: ?>
<!-- hier wird angezeigt dass geschlossen ist -->
<?php endif ?>
@bastianallgeier
bastianallgeier / dataURI.php
Created January 5, 2015 10:54
You can create a dataURI for all your images and other files in Kirby's templates, snippets or plugins. This is super useful for inline CSS for example.
<?php echo $page->image('someimage.jpg')->dataURI() ?>
@bastianallgeier
bastianallgeier / multilangcontent.php
Last active September 17, 2015 02:25
In Kirby's multi-lang version it is super easy to fetch content from different languages in a template.
<?php snippet('header') ?>
<h2>English Version</h2>
<h3><?php echo $page->content('en')->title()->html() ?></h3>
<?php echo $page->content('en')->text()->kirbytext() ?>
<h2>German Version</h2>
<h3><?php echo $page->content('de')->title()->html() ?></h3>
<img src="<?php $page->image()->crop(300, 200)->url() ?>" alt="Cropped by width and height">
<img src="<?php $page->image()->crop(300)->url() ?>" alt="Cropped box">
<img src="<?php $page->image()->resize(300, 200)->url() ?>" alt="Resized by width and height">
<img src="<?php $page->image()->resize(300)->url() ?>" alt="Resized by width only">
<img src="<?php $page->image()->resize(false, 200)->url() ?>" alt="Resized by height only">
<?php
$blogs = $pages->findByUID('blog1', 'blog2');
$articles = $blogs->children()->sortBy('date', 'desc');
// if you want you can add a limit or pagination to that set of articles
// afterwards just use a regular foreach loop to go through them all.
?>
(function($) {
$.fn.smoothScroll = function() {
return this.on('click', function() {
var hash = $(this).attr('href');
var dest = $(hash).offset();
$('html:not(:animated),body:not(:animated)').animate({scrollTop: dest.top, scrollLeft: dest.left}, 500, function() {
window.location.hash = hash;
<ul>
<?php foreach($pages->visible() as $section): ?>
<li><a href="#<?php echo $section->uid() ?>"><?php echo html($section->title()) ?></a></li>
<?php endforeach ?>
</ul>
<?php $article = $pages->find('blog')->children()->last() ?>
<div class="footer">
<div class="container">
<div class="grid full">
// Displays the latest blog article
<h3><?php echo html($article->title()) ?></h3>
<small><?php echo html($article->Published()) ?></small>
<p><?php echo excerpt($article->text(), 250) ?>... <a href="<?php echo html($article->url()) ?>">Continue reading</a></p>
</div>
<div class="cf"></div>
git submodule add https://github.com/getkirby/kirby.git
git submodule add https://github.com/getkirby/panel.git
git submodule update --init --recursive