Skip to content

Instantly share code, notes, and snippets.

View DuaelFr's full-sized avatar

Edouard Cunibil DuaelFr

View GitHub Profile
@DuaelFr
DuaelFr / blocks.inc
Created July 18, 2013 09:39
Show an image field using field_view_field and colorbox
$build = field_view_field('user', $context['entity'], 'field_picture', array(
'label' => 'hidden',
'type' => 'colorbox',
'settings' => array(
'colorbox_node_style' => 'user_large',
'colorbox_image_style' => 'colorbox',
),
));
@DuaelFr
DuaelFr / i18n_check.drush.inc
Last active December 20, 2015 00:18
Drush i18ncheck
<?php
/**
* @file
* Drush module to check if all translatable strings are safe to translate.
*/
/**
* Implements hook_drush_help().
*/
function i18n_check_drush_help($section) {
@DuaelFr
DuaelFr / mymodule-tip.tpl.php
Last active December 21, 2015 10:19
Static block example in Drupal 7
<a href="<?php echo $link_url; ?>" class="<?php echo $link_class; ?>"><?php echo $link_title; ?></a>
@DuaelFr
DuaelFr / gist:6450482
Last active August 5, 2021 06:12
Download a distant file and save it as a local managed file with drupal.
<?php
/**
* Download a file to the destination and save it into drupal managed files.
*
* @param String $url
* The file to download URL.
* @param String $destination
* The path where the file will be stored. Can be a drupal stream like
* "public://my_dowloads" for example.
@DuaelFr
DuaelFr / gist:6683792
Created September 24, 2013 12:09
Hide drupal tabs using a permission
<?php
/**
* Implements hook_permission().
*/
function MYMODULE_permission() {
return array(
'view contextual tabs' => array(
'title' => t('View contextual tabs'),
'restrict access' => TRUE,
<?php if ($main_menu): ?>
<div id="main-menu" class="navigation">
<?php print theme('links__system_main_menu', array(
'links' => $main_menu,
'attributes' => array(
'id' => 'main-menu-links',
'class' => array('links', 'clearfix'),
),
'heading' => array(
'text' => t('Main menu'),
@DuaelFr
DuaelFr / gist:6884247
Created October 8, 2013 12:55
jQuery event resize with timer for performances
function myfunction() {
// Do sth on resize.
}
$(function() {
var intervalId;
$(window).resize(function(e) {
clearTimeout(intervalId);
intervalId = setTimeout(myfunction, 200);
});
@DuaelFr
DuaelFr / mymodule.module
Created November 8, 2013 13:35
Set drupal date formats in the code.
<?php
/*
* Implements hook_date_format_types().
*/
function mymodule_date_format_types() {
variable_set('date_format_date_only', 'd/m/Y');
variable_set('date_format_date_only_evt', 'd F Y');
return array(
'date_only' => t('Date only'),
@DuaelFr
DuaelFr / myprofile.install
Created January 30, 2014 14:07
Enable default language during drupal profile installation
<?php
/**
* @file
* Install, update and uninstall functions for the myprofile installation profile.
*/
/**
* Implements hook_install().
*
* Performs actions to set up the site for this profile.
@DuaelFr
DuaelFr / gist:8820820
Created February 5, 2014 10:30
Extra field with wrappers sample
<?php
/**
* Helper to prepare field renderable array for views extra fields.
*/
function _feature_commons_extra_field_view($field_name, $title, $entity, $view_mode, $langcode, $field_content, $access = TRUE, $entity_type = 'node') {
if (empty($field_content)) {
return '';
}