Skip to content

Instantly share code, notes, and snippets.

View sinsunsan's full-sized avatar

Sébastien LUCAS sinsunsan

View GitHub Profile
@media (max-width:767px) {
#site-description {
display: none;
}
#secondary {
float: none !important;
}
#content {
@sinsunsan
sinsunsan / gist:3705680
Created September 12, 2012 09:59
Change Module Weight / Menu_attributes / d7
/**
* Implements hook_install().
*/
function menu_attributes_install() {
db_update('system')
->fields(array(
'weight' => 10,
))
->condition('type', 'module')
->condition('name', 'menu_attributes')
@sinsunsan
sinsunsan / gist:3705693
Created September 12, 2012 10:03
Define an API to be used by hooks implementation
<?php
/**
* @file
* Documentation for Menu Attributes API.
*/
/**
* Alter the list of menu item attributes.
*
@sinsunsan
sinsunsan / gist:3705709
Created September 12, 2012 10:05
Hook definition / Menu attributes / drupal 7
/**
* Fetch an array of menu attributes.
*/
function menu_attributes_get_menu_attribute_info() {
$attributes = module_invoke_all('menu_attribute_info');
drupal_alter('menu_attribute_info', $attributes);
// Merge in defaul values.
foreach ($attributes as $attribute => &$info) {
$info += array(
<style>
.left-arrow {
border-color: transparent black;
border-style: solid;
border-width: 20px 20px 20px 0px;
height: 0px;
width: 0px;
}
.right-arrow {
<?php
function rue89_assets_asset_view($asset, $view_mode = 'full') {
$asset->content = array();
field_attach_prepare_view('asset', array($asset->aid => $asset), $view_mode);
entity_prepare_view('asset', array($asset->aid => $asset));
$asset->content += field_attach_view('asset', $asset, $view_mode);
//module_invoke_all('asset_view', $asset, $view_mode); // yapp it triggers infinite loop bc of our view fn )
module_invoke_all('entity_view', $asset, 'asset', $view_mode);
@sinsunsan
sinsunsan / drupal behavior.js
Created October 24, 2012 08:59
Validation function in javascript
// status
Drupal.behaviors.statusCheck = {
attach: function (context) {
$('#rue89-register-status-status:not(.status-check-processed)', context)
.each(function() {
var input = $(this).parents('#rue89-register-status').find('input');
Drupal.statusCheck.status = '';
Drupal.statusCheck.validated = false;
input
.focusout(function () {
@sinsunsan
sinsunsan / cancel button.php
Created November 9, 2012 10:05
Add a cancel button to drupal form
<?php
// Code copied from http://drupal.org/node/116939#comment-4906786
function MODULENAME_form_alter(&$form, $form_state, $form_id){
switch ($form_id) {
// This is our form ID.
case 'NODETYPE_node_form':
@sinsunsan
sinsunsan / nodequeue_autocomplete_alter.php
Created November 12, 2012 15:38
Use a view in a autocomplete callback
/**
* Implement hook_autocomplete_alter
*
*/
function common_nodequeue_autocomplete() {
module_load_include('inc', 'nodequeue', 'includes/nodequeue.admin');
$args = func_get_args();
$test = array_shift($args);
if ($test != 'autocomplete') return drupal_json_output(array());
$sqid = array_shift($args);
@sinsunsan
sinsunsan / view_definition.php
Created November 12, 2012 15:50
Exemple of a view 3 definition
$view = new view;
$view->name = 'list_nodes_by_date';
$view->description = '';
$view->tag = 'default';
$view->base_table = 'node';
$view->human_name = 'list nodes by date';
$view->core = 7;
$view->api_version = '3.0-alpha1';
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */