Skip to content

Instantly share code, notes, and snippets.

@texnixe
texnixe / lang-switch.php
Created October 21, 2014 16:39
Kirby 2 Language Switch
<nav class="languages" role="navigation'">
<?php foreach($site->languages() as $language): ?>
<?php $inventory = $page->inventory();
if (array_key_exists($language->code(),$inventory['content'])) :?>
<?php if(($site->language() !== $language)): ?>
<span>
<a href="<?php echo $page->url($language->code()) ?>"><?php echo $language->code(); ?></a>
</span>
<?php endif ?>
<?php endif ?>
@texnixe
texnixe / videoname.videoextension.txt
Last active June 24, 2018 10:10
This template is based on the xmlsitemap.php as described in the Kirby blog article 'Sitemap for search engines' at http://getkirby.com/blog/xmlsitemap. It allows you to include images in your sitemap to inform search engine robots about the images and/or videos belonging to each page indexed in your sitemap. Changes made to the template: - Adde…
Title: Title of Video
----
Description: Description of video
----
Duration: length in minutes
----
Thumb: url/to/thumb/filename
@texnixe
texnixe / longpost.php
Last active February 24, 2017 19:07
Template for [Kirby CMS](http://getkirby.com) that splits long post into several pages where the content file has a <!--pagebreak--> tag. Adds pagination ( prev numbers next). Put <!--pagebreak--> tag into your content file where you want to split the post.
<?php
// store the content of the kirbytext text variable in $text
$text = kirbytext($page->text());
// split the content of $text whenever a <!--pagebreak--> code is encountered and store in the array $pages
$pages = explode('<!--pagebreak-->', $text);
// count the number of pages in the array
$pageCount = count ($pages);
@texnixe
texnixe / language_toggle.php
Created October 4, 2013 12:15
This is a snippet for a multilingual Kirby CMS installation that provides a language toogle with language names instead of language codes. Requires PHP 5.3 and up.
<nav class=lang_toggle>
<?php
$langs=c::get('lang.available');
$current=c::get('lang.current');
foreach($langs as $lang):
?>
<span>
<a href="<?php echo $page->url($lang)?>">
// show language names in the language of the respective languages;
// change second $lang to $current if you want all language names to show in the current language