Skip to content

Instantly share code, notes, and snippets.

@keyral
keyral / gen-d8-salt.sh
Created March 21, 2017 12:42 — forked from pfaocle/gen-d8-salt.sh
Generate Drupal 8 hash salt
drush eval "var_dump(Drupal\Component\Utility\Crypt::randomBytesBase64(55))"
@keyral
keyral / readme.md
Created January 27, 2016 15:46
Stylesheet finder usage

liste des classes de theme

git grep "\.t-" -- assets/src/stylesheets

liste des classes utilitaires

git grep ".u-" -- assets/src/stylesheets

liste des éléménts de composants (BEM)

git grep "__" -- assets/src/stylesheets
$query = new EntityFieldQuery();
$query->entityCondition('entity_type', 'node')
->entityCondition('bundle', 'industry_news_events') // type de contenu industry_news_events
->propertyCondition('status', NODE_PUBLISHED) // qui dois etre publiée
->fieldCondition('field_news_or_event', 'value', 'news', '=') // et on veux que les news
->propertyOrderBy('created', 'desc') // dans l'ordre des derniers création
->range(0,6); // et on veux les 6 derniers
$result = $query->execute();
if($result['node']){
@keyral
keyral / gist:c3778b928df02ffbad54
Created August 27, 2015 09:15
drupal 7 - form api and node reference
//form
$form['node'] = array(
'#type' => 'textfield',
'#title' => t('Tester'),
'#autocomplete_path' => 'test/keyral/ajax',
);
function lolilo_ajax($string = ''){
@keyral
keyral / gist:a04b4ad9bcaf00a100b3
Created June 3, 2015 08:28
drupal 8 block next and preview
namespace Drupal\matthew\Plugin\Block;
use Drupal\Core\Block\BlockBase;
use Drupal\Core\Url;
/**
* Provides a 'Next Previous' block.
*
* @Block(
@keyral
keyral / ckeditor file
Created May 28, 2015 15:26
ckeditor to drupal 8
namespace Drupal\my_ckeditor\Plugin\CKEditorPlugin;
use Drupal\ckeditor\CKEditorPluginInterface;
use Drupal\Component\Plugin\PluginBase;
use Drupal\ckeditor\Annotation\CKEditorPlugin;
use Drupal\Core\Annotation\Translation;
use Drupal\editor\Entity\Editor;
/**
* Defines the "templates" plugin.
@keyral
keyral / gist:7769bca5637201d7f0c1
Created February 2, 2015 12:09
elasticsearch index
<?php
class ElasticsearchIndex {
public $_index;
public $_type;
public $_server;
public $_protocol;
function __construct($protocol, $server, $index, $type){
##########################################################################
#### Script to setup Codio box for Drupal development
##########################################################################
#### Instructions
#### From the Codio Dashboard, create a new Empty template project.
#### Open a Terminal window from the Tools->Terminal window
#### Copy the contents of this file to a file called 'setup.sh' in the root of your machines file system
@keyral
keyral / gist:e14932da88faf61f1572
Created October 9, 2014 08:28
try catch for drupal
try {
} catch (Exception $e) {
drupal_set_message(t('message %message',
array('%message' => $e->getMessage())), 'error');
watchdog('lol', t('Add new items structure : @time sec, name : @name ',
array('@time' => $time_execute,
'@name' =>$item->structure)), array());
}
@keyral
keyral / gist:30e08da5bdc387942552
Created October 8, 2014 08:40
Drupal goto to home page
drupal_goto('<front>');