Skip to content

Instantly share code, notes, and snippets.

View bobdenotter's full-sized avatar
🛠️
"Design is how it works, not how it looks."

Bob den Otter bobdenotter

🛠️
"Design is how it works, not how it looks."
  • Two Kings
  • The Hague, Netherlands
View GitHub Profile
@bobdenotter
bobdenotter / mediaelement.twig
Last active August 22, 2017 21:55
Short example on how to use a MediaElement.js player with Bolt's 'video' field. First, just add a video in Bolt, like this: http://i.imgur.com/EnxqnW3.png . Then, use it in your template, like this:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Mediaelement example</title>
<script src="{{ paths.theme }}javascripts/jquery-1.9.1.min.js"></script>
<script src="http://mediaelementjs.com/js/mejs-2.11.2/mediaelement-and-player.min.js"></script>
<link rel="stylesheet" href="http://mediaelementjs.com/js/mejs-2.11.2/mediaelementplayer.min.css" />
<link rel="stylesheet" href="http://mediaelementjs.com/js/mejs-2.11.2/mejs-skins.css" />
@bobdenotter
bobdenotter / buster.js
Created April 24, 2013 10:52
Bob's definitive Iframe buster buster BUSTER script. Note that the alert _is_ required. Depending on the sophistication of the iframe-buster-buster script, you might want to tweak the time-out (1000, in this case).
<script type="text/javascript">
if (top != self) {
setInterval("alert('Redirecting to example.org, please wait.');top.location.replace('http://example.org/')", 1000);
}
</script>
@bobdenotter
bobdenotter / categories.twig
Created March 18, 2013 12:41
Show all categories in #bolt
{# the array of options, in config.. #}
{{ print(config.taxonomy.categories.options) }}
{# print all options #}
<ul>
{% for category in config.taxonomy.categories.options %}
<li>
<a href="{{ paths.root }}categories/{{category}}">{{category}}</a>
</li>
{% endfor %}
@bobdenotter
bobdenotter / setcontent.twig
Last active December 14, 2015 14:18
#bolt
{% setcontent records = "entries/latest/10" allowpaging %}
{% for record in records %}
<article>
<div class="imageholder"><a href="{{ image(record.image) }}">
<img src="{{ thumbnail(record.image, 400, 260) }}">
</a></div>
<h3><a href="{{ record.link }}">{{ record.title }}</a></h3>
<p>{{ record.excerpt(220) }}</p>
@bobdenotter
bobdenotter / related.twig
Last active December 14, 2015 13:08
#bolt
entries:
name: Entries
singular_name: Entry
fields:
title:
type: text
class: large
slug:
type: slug
uses: title
@bobdenotter
bobdenotter / menu.yml
Last active December 14, 2015 12:59
#bolt
main:
- label: Home
title: First menu item.
path: homepage
class: first
- label: Second item
path: entry/1
submenu:
- label: Sub 1
path: entry/2
All Taxomomies:
{% if record.taxonomy is defined %}
{% for type, values in record.taxonomy %}
<em>{{ type }}:</em>
{% for link, value in values %}
<a href="{{ link }}"></a>
{% if not loop.last %}, {% endif %}
{% endfor %}
{% if not loop.last %} - {% endif %}
{% endfor %}
tags:
slug: tags
singular_slug: tag
behaves_like: tags
categories:
slug: categories
singular_slug: category
behaves_like: categories
multiple: 1
@bobdenotter
bobdenotter / gist:4980044
Created February 18, 2013 19:42
Bolt: When looping over an array to create a list, give the <li> classes like 'first', 'last', 'odd' and 'even'.
<ul>
{% for record in records %}
<li class="{% if loop.first %}first {% endif %}{% if loop.last %}last {% endif %} {{ cycle(["even", "odd"], loop.index) }}">
<a href="{{ record.link }}">{{ record.title }}</a>
</li>
{% endfor %}
</ul>