Skip to content

Instantly share code, notes, and snippets.

View alexroper's full-sized avatar

Alex Roper alexroper

  • Portland, Oregon USA
  • 18:19 (UTC -07:00)
View GitHub Profile
@alexroper
alexroper / matrix-slideshow-example.twig
Created April 22, 2015 17:35
Slideshow with mixed matrix blocks in Craft CMS
{#
# Example of building a slideshow in Craft from adjacent matrix blocks.
#
# This is a technique for getting around the problem of not being able to nest
# matrix fields. Say you're using a matrix field for your 'article-body'
# that has rich-text fields, headings, photos with captions, and slideshows
# all mixed together as different blocks. The slideshow is created by just placing
# single slideshow images (with captions) next to each other in the matrix.
#
# For example:
@alexroper
alexroper / gist:4f6036a70c072efd19de
Created July 24, 2014 20:27
Force training slash in URL with .htaccess
# Force training slash in URL
<IfModule mod_rewrite.c>
RewriteCond %{REQUEST_METHOD} !=POST
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)([^/])$ http://%{HTTP_HOST}/$1$2/ [L,R=301]
</IfModule>
@alexroper
alexroper / .htaccess
Last active August 29, 2015 14:01 — forked from patpohler/gist:7885310
Block bad traffic
#Block hotlinking
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://(.+\.)?mydomain.com [NC]
RewriteRule \.(jpg|jpeg|png|gif|css|js)$ - [NC,F,L]
#Block comment spammers, bad bots and some proxies
RewriteCond %{REMOTE_HOST} 24.117.121.113 [OR]
RewriteCond %{REMOTE_HOST} ^211.138.198.* [OR]
RewriteCond %{REMOTE_HOST} 216.246.60.183 [OR]
RewriteCond %{REMOTE_HOST} 203.94.229.227 [OR]
{if structure:child_ids != '' OR structure:top:entry_id != {structure:page:entry_id}}
<div id="secondary-nav" class="widget">
<h3>Other Pages in <a href="{structure:top:uri}">{structure:top:title}</a>:</h3>
{exp:structure:nav
current_class="active"
start_from="/{segment_1}"
include_ul="yes"
}
</div>
{/if}
<?php
/**
* Custom configuration bootsrtap file for ExpressionEngine
*
* Place config.php in your site root
* Add require(realpath(dirname(__FILE__) . '/../../config_bootstrap.php')); to the bottom of system/expressionengine/config/config.php
* Add require(realpath(dirname(__FILE__) . '/../../config_bootstrap.php')); to the bottom of system/expressionengine/config/database.php
* If you have moved your site root you'll need to update the require_once path
*
<?php
/**
* Custom configuration bootsrtap file for ExpressionEngine
*
* Place config.php in your site root
* Add require(realpath(dirname(__FILE__) . '/../../config_bootstrap.php')); to the bottom of system/expressionengine/config/config.php
* Add require(realpath(dirname(__FILE__) . '/../../config_bootstrap.php')); to the bottom of system/expressionengine/config/database.php
* If you have moved your site root you'll need to update the require_once path
*