Skip to content

Instantly share code, notes, and snippets.

View flocondetoile's full-sized avatar

Flocon de toile flocondetoile

View GitHub Profile
@flocondetoile
flocondetoile / gist:8e1d77dbb6d402540bd9
Created October 27, 2015 17:04 — forked from opi/gist:6078227
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,
<!-- 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]-->
@flocondetoile
flocondetoile / gist:9091f66cd3fe1a39ded3
Created January 14, 2016 22:52 — forked from opi/gist:8470954
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) {
@flocondetoile
flocondetoile / gist:0a0950e56e53683e37fe
Created January 14, 2016 22:55 — forked from opi/gist:6164121
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',
@flocondetoile
flocondetoile / MyBreadcrumbBuilder.php
Created March 22, 2016 11:02 — forked from DuaelFr/MyBreadcrumbBuilder.php
D8 breadcrumb following menus
<?php
/**
* @file
* Contains \Drupal\mymodule\MyBreadcrumbBuilder.
*/
namespace Drupal\mymodule;
use Drupal\Core\Breadcrumb\Breadcrumb;
@flocondetoile
flocondetoile / mymodule.module
Created March 23, 2016 12:06 — forked from DuaelFr/mymodule.module
Drupal GET form without tokens/op in one function.
<?php
function mymodule_myform($form, $form_state) {
$form = [
'#method' => 'GET',
'#action' => url('my_search_page'),
'#token' => FALSE,
'#after_build' => [
function($form) {
$form['form_token']['#access'] = FALSE;
@flocondetoile
flocondetoile / README.md
Created May 25, 2016 11:03 — forked from juampynr/README.md
Sample Guzzle 6 request to Drupal 8 using OAuth 1

This script helps you to test OAuth-signed requests against Drupal 8.

First, make sure that Drupal has been configured by following the steps at https://www.drupal.org/node/2110825. Then install this script with these steps:

  1. Clone this gist.
  2. Run composer.install.
  3. Open oauth_request.php and fill out your consumer_key and consumer_secret. Then Adjust base_uri.
  4. Execute the script with php oauth_request.php.
function my_module_entity_view(&$build, EntityInterface $entity, EntityViewDisplayInterface $display) {
if ($entity instanceof FieldableEntityInterface && $entity->hasField('field_name')) {
foreach (Element::children($build['field_name']) as $item) {
$build['field_name'][$item]['#attributes'] = ['class' => 'my-class'];
}
}
}

Installation d'Apache Solr sur Debian Jessie (pour Drupal 7)

Il semble assez courant d'utiliser le moteur d'indexation Apache Solr pour Drupal via la panoplie de module autour de Search API.

Mais installer Solr n'est pas aussi simple qu'installer un module Drupal. Voici donc un guide d'installation, basé sur Debian Jessie.

Pré-requis

Apache Solr en développé en Java, il nous faut donc installer la plateforme d'execution JRE (Java Runtime Environment).

@flocondetoile
flocondetoile / Flip.css
Created November 18, 2016 20:14 — forked from smockle/Flip.css
Flip demonstrates a flip animation using CSS. Tested in Google Chrome 26, IE 10, and Firefox Nightly.
/* entire container, keeps perspective */
body .flip-container {
width: 100%;
}
body .flip-container .flipper {
position: relative;
}
/* hide back of pane during swap */