Skip to content

Instantly share code, notes, and snippets.

@opi
opi / gist:6078227
Last active June 8, 2017 09:52
Simple social links extra_field for drupal.
<?php
// Social share links
$links = array();
$share_url = url('node/'.$node->nid, array('absolute' => TRUE));
$links['facebook'] = array(
'href' => 'https://www.facebook.com/sharer/sharer.php?u='.$share_url,
'title' => t("Facebook"),
'attributes' => array(
'data-popup-width' => 700,
@opi
opi / gist:6087056
Created July 26, 2013 07:53
Drupal wysiwyg drush make
libraries[ckeditor][download][type]= "get"
libraries[ckeditor][directory_name] = "ckeditor"
libraries[ckeditor][destination] = "libraries"
; Le lien suivant peut expirer, voir http://drupal.org/node/1943098#comment-7234212
libraries[ckeditor][download][url] = "http://ckeditor.com/online-builder/releases/minified/4.1.2/moono/4.1.2/ckeditor_4.1.2_b252dac9fef6.zip"
; sinon le zip normal
libraries[ckeditor][download][url] = "http://download.cksource.com/CKEditor/CKEditor/CKEditor%204.2/ckeditor_4.2_standard.zip"
; Get TinyMCE library, and its French translation (to be used with WYSIWYG module).
@opi
opi / .bashrc
Created August 1, 2013 12:17
Bash git prompt and completion
# Git autocompletion
source ~/.git-completion.sh
# prompt
source ~/.git-prompt.sh
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w $(__git_ps1 "(%s)")$ '
@opi
opi / gist:6131176
Last active December 20, 2015 12:29
Drupal : text => link formatter
<?php
/**
* Implements hook_field_formatter_info().
*/
function mymodule_field_formatter_info() {
return array(
'mymodule_link' => array(
'label' => 'Link for ingenie site/email',
'field types' => array('text'),
@opi
opi / gist:6164121
Created August 6, 2013 12:43
Drupal: tabbed block with jQuery UI
<?php
function my_module_my_tabbed_block() {
// Block title
$block['subject'] = t("My tabbed block");
// Tabs.
$block['nav'] = array(
'#theme' => 'item_list',
@opi
opi / gist:6761390
Last active December 24, 2015 07:08
drupal 7 gitignore
# Ignore configuration files that may contain sensitive information.
sites/*/*settings*.php
# Ignore paths that contain generated content.
cache/
files/
sites/*/files
sites/*/private
# Drupal develepment modules
@opi
opi / gist:6882634
Created October 8, 2013 10:19
drush custom local command
<?php
/**
* Implements hook_drush_command().
*/
function custom_local_drush_command() {
$items['files-fix-permissions'] = array(
'description' => 'Fix file permissions',
'aliases' => array('ffp'),
);
@opi
opi / gist:7431393
Last active December 28, 2015 02:59
Drupal 7 : Restrict searchable content type
<?php
/**
* Implements of hook_query_node_access_alter().
*/
function MYMODULE_query_node_access_alter(QueryAlterableInterface $query) {
$search = FALSE;
$node = FALSE;
foreach ($query->getTables() as $alias => $table) {
@opi
opi / gist:8438657
Created January 15, 2014 15:50
touch event js
/**
* Touch events
*/
wrapper.touch = {}
wrapper.get(0).ontouchstart = function(e) {
// Store start position
wrapper.touch.x = e.touches[0].clientX;
};
@opi
opi / gist:8470954
Created January 17, 2014 10:08
Drupal 7 Search language and content type
<?php
/**
* Implements of hook_query_node_access_alter().
*/
function MYMODULE_query_node_access_alter(QueryAlterableInterface $query) {
$search = FALSE;
$node = FALSE;
foreach ($query->getTables() as $alias => $table) {