Skip to content

Instantly share code, notes, and snippets.

Mark Carver markcarver

Block or report user

Report or block markcarver

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View 1-issue.comments.alter.js
/**
* THIS FILE ALTERS ANY ISSUE WITH THE NEW STYLING. IT AUTOMATICALLY INCLUDES THE CSS FILE
* BELOW. JUST COPY AND PASTE THIS IN YOUR INSPECTOR CONSOLE.
**/
(function ($) {
var localStorageSupported = false;
var enableTimeago = false;
// Only enable timago if user's browser has localStorage support (so they can
// double click to enable and disable at will).
if (typeof window.localStorage !== 'undefined') {
View classes.twig
{% attributes.class.add([
'node',
'node--type-' ~ node.bundle|class,
node.promoted ? 'node--promoted',
node.sticky ? 'node--sticky',
not node.published ? 'node--unpublished',
preview ? 'node--preview',
'node--view-mode-' ~ view_mode|class
]).remove([
'some-module-class'
@markcarver
markcarver / stark2.theme.php
Created Jul 8, 2014
Adding external/inline resources via #attached in a Drupal 8 theme
View stark2.theme.php
<?php
/**
* @file
* Example of how to attach external and inline resources for a theme via the
* #attached render array method in 8.x.
*/
/**
* Helper function for attaching resources to a render array.
*/
View item-list-empty.php
<?php
$items = array();
$build['list'] = array(
'#theme' => 'item_list',
'#items' => $items,
'#empty' => t('You have no content, please <a href="!link">create some</a>.', array(
'!link' => 'node/add',
),
@markcarver
markcarver / menu-tree.vars.php
Last active Aug 29, 2015
Menu tree context alter
View menu-tree.vars.php
<?php
/**
* Implements hook_theme_registry_alter().
*/
function THEMENAME_theme_registry_alter(&$theme_registry) {
array_unshift($theme_registry['menu_tree']['preprocess functions'], 'THEMENAME_menu_tree_alter');
}
/**
* Helper function for adding the tree context to the variables.
@markcarver
markcarver / bot.conf
Created Mar 20, 2015
Create this file as /etc/init/bot.conf
View bot.conf
# Drush Bot Service
description "Drush Bot"
author "Mark Carver <mark.carver@me.com>"
start on runlevel [2345]
stop on starting rc RUNLEVEL=[016]
respawn
respawn limit 2 5
@markcarver
markcarver / page.tpl.php
Created Nov 23, 2011
Replaceable Image Theme Settings
View page.tpl.php
<?php
/**************
* IMPORTANT:
* Place these styles in your page.tpl.php file to override the style.css.
* You will need to make sure they match your themes selectors.
**************/
?>
<style type="text/css" media="all">
#page{
background-attachment:<?php print $background_image_attachment; ?>;
@markcarver
markcarver / 1-template.php
Created Nov 5, 2012
Drupal 7 - Converting a Views Unformatted List Into Columns
View 1-template.php
<?php
/**
* Implements hook_preprocess_views_view_unformatted().
*/
function YOUR_THEME_preprocess_views_view_unformatted(&$variables) {
// Determine if this view's content should render in columns.
// @see: _YOUR_THEME_views_columns();
_YOUR_THEME_views_columns($variables, array(
'articles|page' => 2,
@markcarver
markcarver / d8-reset.sh
Created Jul 21, 2013
Deletes settings.php, removes the php config dir, drops and creates the database table.
View d8-reset.sh
#!/bin/bash
sudo rm -rf /sandbox/sites/d8.sandbox/sites/default/settings.php;
sudo rm -rf /sandbox/sites/d8.sandbox/sites/default/files/php/;
mysql -u root -proot -e 'DROP DATABASE `d8.sandbox`; CREATE DATABASE `d8.sandbox`;'
@markcarver
markcarver / perm.sh
Created Jul 21, 2013
Change the ownership settings according to how your www environment is setup.
View perm.sh
#!/bin/bash
echo 'Setting ownership to _www:staff ...';
sudo chown -R _www:staff ./;
echo 'Setting directory permissions to 0755 ...';
sudo find . -type d -exec chmod u=rwx,g=rwx,o=rx '{}' \;
echo 'Setting file permissions to 0644 ...';
sudo find . -type f -exec chmod u=rw,g=rw,o=r '{}' \;
You can’t perform that action at this time.