Skip to content

Instantly share code, notes, and snippets.

View rossriley's full-sized avatar

Ross Riley rossriley

View GitHub Profile
## This is how it should look
news:
name: News
singular_name: Article
slug: latest
fields:
title:
type: text
class: large
<?php
//
// this file sits in public/index.php
require_once "../vendor/autoload.php";
$configuration = new Bolt\Configuration\Standard(dirname(__DIR__));
$configuration->setPath("web","public");
$configuration->setPath("files","public/files");
$configuration->setPath("themebase","public/theme");
@rossriley
rossriley / gist:fdc9f545a8f122215334
Last active August 29, 2015 14:17
Using Anchors and Refs for Bolt Contenttypes
pages:
name: Pages
singular_name: Page
field_defaults: &defaults
title:
type: text
class: large
slug:
type: slug
uses: title
@rossriley
rossriley / gist:bb16ea1b7933292a12a4
Created April 9, 2015 12:07
How to adjust upload size by contenttype
$app->initialize();
$app['upload'] = $app->extend('upload', function ($handler, $app) {
if ($app['request']->get('contenttype') == 'pages') {
$handler->addRule('size', ['size' => '100K'], '{label} uploads are limited to {size}', 'Page Image');
}
return $handler;
});
$app->run();
@rossriley
rossriley / gist:977339ed752337173819
Created April 15, 2015 10:29
Use DI Managed Controllers in Bolt
<?php
// in Myapp/Provider/ControllerProvider.php
namespace Myapp\Provider;
use Silex\ServiceProviderInterface;
use Silex\Application;
use Myapp\Routing\ControllerResolver
/**
# 1. composer.json
{
"name": "ross/myproject",
"description": "My Project",
"license": "proprietary",
"require": {
"bolt/bolt": "~2.1",
.... other requirements
@rossriley
rossriley / gist:a1647629c70a0336df4f
Last active August 29, 2015 14:23
Custom Configuration
<?php
namespace Boorj\Bolt;
use Bolt\Configuration\Standard;
use Symfony\Component\HttpFoundation\Request;
class Configuration extends Standard
{
/**
@rossriley
rossriley / gist:695b62ade55e6ac88f40
Created June 18, 2015 19:23
Custom Controller to switch templates
<?php
namespace My\Custom\Controller;
use Bolt\Controllers\Frontend as BoltFrontend;
class Frontend extends BoltFrontend {
public function record(Request $request, $contenttypeslug, $slug = '')
{
parent::record($request, $contenttypeslug, $slug);
@rossriley
rossriley / gist:1d98314f248bdec38037
Last active August 29, 2015 14:23
Virtualhost config for apache
NameVirtualHost *:80
<VirtualHost *:80>
VirtualDocumentRoot /home/%1/public
UseCanonicalName Off
SetEnv ENV production
<Directory /home/>
Options Indexes FollowSymLinks MultiViews
Require all granted
</Directory>
@rossriley
rossriley / gist:44880d8359c8efbd81e6
Created June 29, 2015 13:06
Width/Height to bolt thumbs
<?php
public function parseResizedImages($text) {
$doc = new DOMDocument();
@$doc->loadHTML($text);
$tags = $doc->getElementsByTagName('img');
foreach ($tags as $tag) {
if (substr($tag->getAttribute("src"),0,7) == "/files/") {
if ($wid = $tag->getAttribute("width")) {
$pathParts = pathinfo($tag->getAttribute("src"));