Skip to content

Instantly share code, notes, and snippets.

@GoZOo
GoZOo / Drupal::Url
Created October 3, 2014 07:53
Drupal 8 implements url
in a hook, call Drupal::url() directly;
in a controller or a form or something like that, use the UrlGeneratorTrait (for forms at least it's already there for you),
for services, inject the 'url_generator' in your class by adding it in your service definition
@GoZOo
GoZOo / .gitconfig
Last active March 16, 2017 10:45
Gitconfig
[core]
excludesfile = ~/.gitignore_global
autocrlf = input
[alias]
# Diff
d = diff --patch-with-stat
# Diff staged
ds = diff --staged --patch-with-stat
# Undo a `git push`
undopush = push -f origin HEAD^:master
@GoZOo
GoZOo / drupal7
Last active August 29, 2015 14:07
Simple Nginx configuration for Drupal
# file templates/drupal7
charset utf-8;
error_page 404 = @drupal;
error_page 405 = @drupal;
index index.html index.php;
location = /favicon.ico {
log_not_found off;
access_log off;
@GoZOo
GoZOo / media_field_formapi.php
Last active December 22, 2015 20:08
Manage media field with form api forms for Drupal 7 administration pages
<?php
/**
* Manage media field with form api forms for administration pages
* Depends of media module http://dgo.to/media
**/
/**
* Function called by drupal_get_form()
**/
function myform($form, &$form_state) {
@GoZOo
GoZOo / install-lamp.bash
Last active December 22, 2015 19:39
Installation d'un serveur lamp basique pour drupal
apt-get install apache2 php5 mysql-server phpmyadmin git-core vim curl php5-curl sendmail
# active apache mods
a2enmod rewrite headers expires
# install pear
wget http://pear.php.net/go-pear.phar
php go-pear.phar
# install drush
@GoZOo
GoZOo / settings-fast_404.patch
Last active December 21, 2015 12:38
Patch to add fast_404 extensions configuration for nvosprofile on settings.php
From 645f985760acee829817832a9922929874007f20 Mon Sep 17 00:00:00 2001
From: GoZ <[email protected]>
Date: Thu, 22 Aug 2013 15:13:31 +0200
Subject: [PATCH] Add settings for fast_404
---
sites/default/default.settings.php | 78 ++++++++++++++++++++++++++++++++++++
1 files changed, 78 insertions(+), 0 deletions(-)
diff --git a/sites/default/default.settings.php b/sites/default/default.settings.php
@GoZOo
GoZOo / exclude-content-from-search.php
Created June 4, 2013 08:15
Drupal code: Exclude some content types from node search
<?php
/**
* Implements of hook_query_node_access_alter().
* Exclude some content types from node search
* Ne pas prendre en compte certains types de contenu dans la recherche
*/
function mymodule_query_node_access_alter(QueryAlterableInterface $query) {
global $user;
// No exclude for super admin
@GoZOo
GoZOo / blockadmin_example.admin.inc
Created April 26, 2013 13:48
Example for make blocks easily configurable for webmaster without 'administer blocks' access (and without huge permissive module). This fully use formapi (http://api.drupal.org/node/15320) and custom code.
<?php
function blockadmin_example_admin() {
$text = variable_get('blockadmin_example_page_text', array('format'=> 'filtered_html', 'value'=> ""));
$form['blockadmin_example_page_text'] = array(
'#type' => 'text_format',
'#format' => $text['format'],
'#title' => t('Texte'),
'#default_value' => $text['value'],
@GoZOo
GoZOo / vset_local.sh
Created April 9, 2013 12:31
script to re-configure development variables after database update
#!/bin/bash
# MOBILE
drush vset mobile_tools_mobile_url "http://m.local.mysite.com"
drush vset mobile_tools_desktop_url "http://local.mysite.com"
# modules
drush dl -y dummyimage
drush en -y devel dummyimage
# dummyimage
@GoZOo
GoZOo / createUserVirtualhostDb.bash
Last active December 15, 2015 16:49
Script bash pour créer un utilisateur, son virtualhost (avec SSL) et sa base de données. Nécessite que le fichier à partir duquel la configuration VirtualHost existe déjà (/root/apache2-default et /root/apache2-default-ssl) Idem pour le .bashrc : /etc/root/.bashrc-default
#! /bin/bash
######################
## Script de création de virtualhost + utilisateur + base de données
######################
## /!\ Penser a modifier [ROOTPASSWORD] pour mysql
######################
## USER
# Prompt user informations