Skip to content

Instantly share code, notes, and snippets.

View rossriley's full-sized avatar

Ross Riley rossriley

View GitHub Profile
$app['upload'] = $app->share(
$app->extend(
'upload',
function ($upload, $app) {
$upload->setSanitizerCallback(
function ($filename) use () {
// do custom sanitising here...
}
);
{% for name,field in record.contenttype.fields %}
{% if field.type == 'text' %}
{{ record.get(name) }}
{% endif %}
{% endfor%}
var CKEDITORPluginExtras = false;
if (typeof(CKEDITOR) != 'undefined' ) {
CKEDITOR.on('instanceReady',function(event, instance){
if (CKEDITORPluginExtras) {
return;
}
var config = event.editor.config;
CKEDITOR.instances.body.destroy();
@rossriley
rossriley / contenttypes.yml
Last active November 10, 2015 19:01
Repeating Fields Config
# Add to bottom of fields within showcases
repeat:
type: repeater
group: repeats
limit: 3
prefix: "<p>This allows you to create multiple sets of fields. Use the add button at the bottom to create a new empty set.</p>"
postfix: "<p>This is a postfix</p>"
fields:
reptitle:
type: text
$app['upload'] = $app->extend('upload', function ($handler, $app) {
if ($app['request']->get('contenttypeslug') && $app['request']->get('id')) {
$handler->setPrefix("/".$app['request']->get('contenttypeslug')."/".date("Y-m"));
}
return $handler;
});
SELECT content.*, GROUP_CONCAT(DISTINCT entries.to_id) as entries FROM bolt_showcases content LEFT JOIN bolt_relations entries ON ((content.id = entries.from_id) AND (entries.from_contenttype = :boltname) AND (entries.to_contenttype = :field)) OR ((content.id = entries.to_id) AND (entries.to_contenttype = :boltname) AND (entries.from_contenttype = :field)) GROUP BY content.id
SELECT content.*, GROUP_CONCAT(DISTINCT entries.to_id) as entries FROM bolt_showcases content LEFT JOIN bolt_relations entries ON content.id = entries.from_id AND entries.from_contenttype='showcases' AND entries.to_contenttype='entries' GROUP BY content.id
## in sections.yml or at the top of contenttypes.yml
# inside a fields block in contenttypes.yml
people:
type: repeater
limit: 3
fields:
name:
type: text
class: large
@rossriley
rossriley / bootstrap.php
Created September 9, 2015 18:25
Add a contenttype / id prefix to an image upload path
<?php
// Appears in your bootstrap file, before the call to $app->run()
$app['upload'] = $app->extend('upload', function ($handler, $app) {
if ($app['request']->get('contenttype') == 'pages') {
if ($app['request']->get('contenttypeslug') && $app['request']->get('id')) {
$handler->setPrefix("/".$app['request']->get('contenttypeslug')."/".$app['request']->get('id'));
}
}
return $handler;
1: Make this class
<?php
namespace Mysite\Bolt;
use Bolt\Application;
use Bolt\BaseExtension;
class GetEventsExtension extends BaseExtension
@rossriley
rossriley / gist:c74fdee4fec3eaffb12f
Last active August 29, 2015 14:24
Add local resources to Bolt translations
<?php
namespace MySite\Bolt\Provider;
use Silex\ServiceProviderInterface;
use Silex\Application;
use Symfony\Component\Translation\Loader\YamlFileLoader;
/**
*
*/