Skip to content

Instantly share code, notes, and snippets.

View sjelfull's full-sized avatar

Fred Carlsen sjelfull

View GitHub Profile
<?php
$ignore = array('sitemap', 'error');
// send the right header
header('Content-type: text/xml; charset="utf-8"');
// echo the doctype
echo '<?xml version="1.0" encoding="utf-8"?>';
<?php
class kirbytextExtended extends kirbytext {
function __construct($text, $markdown=true) {
parent::__construct($text, $markdown);
// define custom tags
$this->addTags('figure');
<?php namespace Forge;
class PrettyName {
/**
* An array of adjectives.
*
* @var array
*/
protected static $adj = [

###Multi-language routing with Resource Router

The idea is to set up ISO 639-1 language code prefixes for urls (e.g. en/, de/, fr/), and set global variables {global:lang} and {global:lang_dir} for use in your templates.

In the control panel create a category group "languages" and populate it with your languages, setting the category url title to the appropriate 2-letter language code. Assign the category group to the channels you want to translate.

For example:

Category Name Category URL Title
@sjelfull
sjelfull / varnish-craft.vcl
Created February 19, 2015 13:01 — forked from aelvan/gist:eba03969f91c1bd51c40
Varnish 4.0 file for our Craft CMS projects
# Varnish 4.0 file for our Craft CMS projects
# Based on https://github.com/mattiasgeniar/varnish-4.0-configuration-templates/blob/master/default.vcl
#
# This is still work in progress, comments appreciated.
vcl 4.0;
import std;
import directors;
@sjelfull
sjelfull / csi-esi.js
Last active August 29, 2015 14:16 — forked from nikosd/csi-esi.js
/*
* ESI Parser 1.00 - Poor Man's ESI
*
* - or - I'm tired of seeing the wrong thing in my browser while developing.
*
* This code provides a client-side ESI parsing capability. It was created
* to provide an easier way of developing and testing sites that use ESI
* when not behind the cache or other system that provides the ESI parsing.
* It requires jQuery (anything after v1.2 should be fine)
*
<?php
namespace Craft;
class EntryTypeSourcesPlugin extends BasePlugin
{
public function getName()
{
return Craft::t('Entry Type Sources');
}
@sjelfull
sjelfull / nav.html
Last active August 29, 2015 14:21 — forked from MisterPoppet/nav.html
{% macro menu(items, class, home) %}
{% import _self as parts %}
<div class="lucky {{ class|default('main') }} menu">
{% if home|default(true) %}
<a href="{{ siteUrl }}">Home</a>
{% endif %}
{{ parts.menuItems(items) }}
</div>
{% endmacro %}
@sjelfull
sjelfull / TitleToSettingsPanePlugin.php
Last active August 29, 2015 14:25
Craft CMS: Simple (and not very well tested!) plugin to move the title field to the settings pane.
<?php
namespace Craft;
class TitleToSettingsPanePlugin extends BasePlugin {
/**
* Returns the plugin’s name.
*
* @return string The plugin’s name.
*/
/**
* tabfocus event plugin for jQuery
*
* Mimics the focus() event, except it's only
* called when focus wasn't assigned via a click
*
* -------------------------------------------
* Usage
* -------------------------------------------
*