Skip to content

Instantly share code, notes, and snippets.

@opi
opi / gist:df0b6429cfabe41b1dca
Last active August 29, 2015 14:22
Drupal : Global class for long text elements
<?php
/**
* Implements template_preprocess_field().
*/
function EXAMPLE_preprocess_field(&$vars) {
/*
* theme_hook_suggestion:
* $variables['theme_hook_suggestions'] = array(
'field__' . $element['#field_type'],
@opi
opi / gist:0b6496d25674841601ba
Created May 7, 2015 16:23
Vertical Centering
<!doctype html>
<html class="no-js" lang="">
<head>
<meta charset="utf-8">
<title>Vertical centering - 3WA</title>
<style>
/* border box ftw*/
*, *::before, *::after {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
@opi
opi / gist:9f3807679f63f299fe28
Last active August 29, 2015 14:20
Font size
body {
font-size: 62.5%; /* font-size 1em = 10px */
}
p {
font-size: 1.6em; /* 1.6em = 16px */
}
@opi
opi / gist:8750eba32e4a02efa752
Created May 6, 2015 09:27
enlarge your click
// From https://github.com/opi/basement/blob/7.x-1.x/js/basement.js#L29
// Enlarge Your Click Zone : allow link'parent element to be clickable too
var enlargeYourClick = function(selector){
$(selector).click(function(e){
// don't handle if user click on a link, or if he click with mouse wheel
if (e.target.tagName != "A" && e.button != 1) {
var firstLink = $(this).find('a:first'),
dest = firstLink.attr('href'),
blank = firstLink.attr('target');
@opi
opi / gist:ca4b97b5614683fe2bf2
Last active January 14, 2016 22:48
Browse Happy
<!-- Placer ce code directement après l'ouverture du <body> -->
<!--[if lte IE 9]>
<p class="browsehappy">Vous utilisez un navigateur <strong>dépassé</strong>. Merci de <a href="http://browsehappy.com/">mettre à jour votre navigateur</a> pour améliorer votre expérience sur ce site.</p>
<![endif]-->
<!-- Favicons -->
<link rel="apple-touch-icon" sizes="57x57" href="/icon/apple-touch-icon-57x57.png">
<link rel="apple-touch-icon" sizes="114x114" href="/icon/apple-touch-icon-114x114.png">
<link rel="apple-touch-icon" sizes="72x72" href="/icon/apple-touch-icon-72x72.png">
<link rel="apple-touch-icon" sizes="144x144" href="/icon/apple-touch-icon-144x144.png">
<link rel="apple-touch-icon" sizes="60x60" href="/icon/apple-touch-icon-60x60.png">
<link rel="apple-touch-icon" sizes="120x120" href="/icon/apple-touch-icon-120x120.png">
<link rel="apple-touch-icon" sizes="76x76" href="/icon/apple-touch-icon-76x76.png">
<link rel="apple-touch-icon" sizes="152x152" href="/icon/apple-touch-icon-152x152.png">
<link rel="icon" type="image/png" href="/icon/favicon-196x196.png" sizes="196x196">
@opi
opi / gist:576b81d7e4d0e5325107
Created March 17, 2015 08:43
Drupal : Create fields with drush
drush field-create CONTENT_TYPE field_FIELD_NAME,text_long,text_textarea
drush field-create CONTENT_TYPE field_FIELD_NAME,text,text_textfield
drush field-create CONTENT_TYPE field_FIELD_NAME,list_text,options_select
drush field-create CONTENT_TYPE field_FIELD_NAME,number_integer,number
drush field-create CONTENT_TYPE field_FIELD_NAME,number_decimal,number
@opi
opi / gist:45de0e8258b82d298dc5
Created February 26, 2015 11:18
Drupal Fix seven CSS for wysiwyg textfields
/* Fix seven CSS stupidity */
.wysiwyg-toggle-wrapper {
border-left: 1px solid #ccc;
border-right: 1px solid #ccc;
padding: 0 8px;
}
.filter-wrapper,
.wysiwyg-toggle-wrapper {
margin-right: 1px;
@opi
opi / gist:c0cb89a3b7c934c5fe7a
Created February 6, 2015 14:26
Drupal paragraphs summary
<?php
/**
* @file
* Holds relevant functions for paragraph field formatters.
*/
/**
* Implements hook_field_formatter_info().
*/
@opi
opi / gist:5200c4ff5c298ad3103e
Created January 15, 2015 10:29
Drupal list all public views urls (page & feed)
<?php
// Views page and feeds list
$views = array();
foreach (views_get_enabled_views() as $view_name => $view) {
// Filter views having no display
if (count($view->display) > 1 && (strpos($view_name, 'admin') === FALSE)) {
$views[$view_name] = array(
'#theme' => 'item_list',
'#title' => $view->human_name,