Skip to content

Instantly share code, notes, and snippets.

View flashvnn's full-sized avatar

Huynh Khac Thao flashvnn

View GitHub Profile
@flashvnn
flashvnn / bean_revisions.php
Created February 25, 2014 05:59
Quick Fix to Disable Bean Revisions
<?php
function MYMODULE_form_bean_form_alter(&$form, &$form_state) {
// Hide the revision checkbox.
$form['revision']['is_new_revision']['#type'] = 'hidden';
// Make "Create new revision" off by default
$form['revision']['is_new_revision']['#default_value'] = 0;
// Hide the revision log field.
@flashvnn
flashvnn / twig_flexslider.php
Last active August 29, 2015 13:57
Twig Flexslider
$preset = new stdClass();
$preset->disabled = FALSE; /* Edit this to true to make a default preset disabled initially */
$preset->api_version = 1;
$preset->name = 'flexslider';
$preset->title = 'FlexSlider';
$preset->html = '<div class="flexslider">
<ul class="slides">
{% for item in data %}
<li>
<img src="{{item.image}}" />
@flashvnn
flashvnn / twig_liquidSlider.php
Last active August 29, 2015 13:57
twig_liquidSlider
$preset = new stdClass();
$preset->disabled = FALSE; /* Edit this to true to make a default preset disabled initially */
$preset->api_version = 1;
$preset->name = 'liquid_slider';
$preset->title = 'Liquid Slider';
$preset->html = '<div class="liquid-slider" id="slider-id">
{% for item in data %}
<div>
<h2 class="title">{{item.title}}</h2>
{{item.description|raw}}
<?php
function famiana_helper_field_widget_image_image_form_alter(&$element, &$form_state, $context) {
foreach (element_children($element) as $item) {
$element[$item]['#process'][] = 'famiana_helper_image_field_widget_process';
}
}
function famiana_helper_image_field_widget_process($element, &$form_state, $form){
@flashvnn
flashvnn / drupal-no-cache-header.php
Created April 28, 2014 07:25
Drupal disable cache on page prevent click "Back" button
<?php
// Add header to prevent cache on page.
drupal_add_http_header('Cache-Control', 'no-store, no-cache, must-revalidate, no-transform, max-age=0, post-check=0, pre-check=0');
drupal_add_http_header('Pragma', 'no-cache');
?>
@flashvnn
flashvnn / ckeditor.config.js
Created May 7, 2014 04:29
Fix CKEditor From Setting Image Dimensions
/*
* --------------------------------------------------------------------
* EDITOR CONFIGURATION
* --------------------------------------------------------------------
*
* Create default configuration settings, to be used by all Wygwam fields.
* See http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.config.html
*
*/
CKEDITOR.editorConfig = function( config )
@flashvnn
flashvnn / template.php
Created May 7, 2014 04:34
Remove query strings from static resources drupal
<?php
/**
* Implements template_process_html().
*/
// Remove Query Strings from CSS filenames (CacheBuster)
function MYTHEME_process_html(&$variables) {
$variables['styles'] = preg_replace('/\.css\?.*"/','.css"', $variables['styles']);
}
@flashvnn
flashvnn / fft-inline-tags.tpl.php
Created May 12, 2014 04:01
Field formmater template: inline tags
<?php
/*Template Name: Inline Tags*/
// dpm($data);
$tags = array();
foreach ($data as $key => $item) {
$tags[] = l($item['name'], "taxonomy/term/" . $item['tid']);
}
print implode(" | ", $tags);
@flashvnn
flashvnn / drupal_composer_autoload.php
Created May 12, 2014 09:06
Drupal Composer Add autoload class at runtime.
<?php
function illuminate_example_page(){
$loader = ComposerAutoloaderInitComposerManager::getLoader();
$loader->add("Drupal\\illuminate_example\\Example", drupal_get_path("module", "illuminate_example") . "/lib");
return "OK";
}
?>
@flashvnn
flashvnn / ckeditor.styles.js
Created May 14, 2014 01:58
Drupal CKEDITOR configuration to work with bootstrap theme
/*Reference: http://www.aglobalway.com/content/drupal-ckeditor-configuration-work-bootstrap-theme*/
/* Bootstrap Styles */
/* Typography */
{ name : 'span.H1' , element : 'span', attributes: { 'class': 'h1' } },
{ name : 'span.H2' , element : 'span', attributes: { 'class': 'h2' } },
{ name : 'span.H3' , element : 'span', attributes: { 'class': 'h3' } },
{ name : 'span.H4' , element : 'span', attributes: { 'class': 'h4' } },
{ name : 'span.H5' , element : 'span', attributes: { 'class': 'h5' } },
{ name : 'span.H6' , element : 'span', attributes: { 'class': 'h6' } },