Skip to content

Instantly share code, notes, and snippets.

@keeprock
keeprock / index.htm
Last active August 29, 2015 14:16
Link to open node in a popup using Vpop Module
<a href="/ajax/popup/node/[NID]/nojs" class="use-ajax">SOME_TEXT_HERE</a>
@keeprock
keeprock / custom.module.php
Created February 27, 2015 12:29
Adding placeholder for empty select box
function custom_form_alter(&$form, &$form_state, $form_id) {
if ($form_id == 'WEBFORM_ID') {
$form['submitted']['WEBFORM_FIELD_NAME']['#empty_option'] = 'TEXT';
}
}
@keeprock
keeprock / custom.module.php
Last active August 29, 2015 14:16
Access variables from PHP in Javascript
drupal_add_js(array('VAR_JS' => $VAR_PHP), 'setting');
// Alternative
drupal_add_js(array('CUSTOM_MODULE' => array('KEY' => 'value')), 'setting');
@keeprock
keeprock / custom.module.php
Last active September 11, 2015 13:58
Loads views with ajax. - Generating links with special addresses - Creating menu item with ajax page callback - Writing ajax callback with Drupal Ajax functions - Loading view with contextual filters (from url) - Replace view with Drupal Ajax functions
function custom_menu() {
$items = array();
$items['ajax/custom_module/custom_action/%/%'] = array(
'title' => 'Title',
'delivery callback' => 'ajax_deliver', // important here!
'page callback' => 'custom_module__pagecallback',
'page arguments' => array(3,4), // index starts with zero
'type' => MENU_CALLBACK,
@keeprock
keeprock / style.css
Created February 26, 2015 06:29
Ajax throbber classes
.ajax-progress-throbber, .ajax-progress-throbber .message, .ajax-progress-throbber .throbber {
}
@keeprock
keeprock / pagination.js
Last active August 29, 2015 14:16
Caroufredsel basic skeleton call # update 1 with pagination
var specials = $('.specials-list ul li');
if (specials.length) {
specials.parent().carouFredSel({
items: {
width: 590,
visible: 1
},
pagination: {
@keeprock
keeprock / page.tpl.php
Created February 24, 2015 09:37
Print a variable using Voodoo blocks
<?php print $vh['var_name']; ?>
@keeprock
keeprock / new_gist_file_0
Created February 24, 2015 09:26
Form placeholder code style
webform-client-form-ID|name_of_the_field|Label to put
@keeprock
keeprock / page.tpl.php
Last active August 29, 2015 14:16
Link to open a modal window with a webform. Class "ctools-use-modal" used here to hook up with a Ctools Ajax dialog module. Absolutely necessary.
<a class="ctools-use-modal ctools-modal-modal-popup-STYLE-OF-THE-WEBFORM(small, medium, large)"
href="/modal_forms/nojs/webform/ID-OF-THE-WEBFORM">Open a webform</a>
@keeprock
keeprock / custom.info
Last active August 29, 2015 14:16
Display block regions inside template
regions[name_of_the_region] = Description of the block