Skip to content

Instantly share code, notes, and snippets.

// the required fields that we want to ignore
//$safe_fields = array('field_test2');
//just grab all fields in the second field group
$safe_fields = $form['#groups']['group_option2']->children;
// get a list of all errors
$errors = form_get_errors();
// this will clear Error msg queue
$messages = drupal_get_messages('error');
@segovia94
segovia94 / Toggle all checkboxes bookmark.js
Last active August 29, 2015 14:01
Toggle all checkboxes
//requires jQuery 1.6 minimum
var $checkBoxes = $('input:checkbox');
$checkBoxes.prop("checked", !$checkBoxes.prop("checked"));
//bookmarklet created via: http://benalman.com/code/test/jquery-run-code-bookmarklet/
javascript:(function(e,a,g,h,f,c,b,d){if(!(f=e.jQuery)||g>f.fn.jquery||h(f)){c=a.createElement("script");c.type="text/javascript";c.src="http://ajax.googleapis.com/ajax/libs/jquery/"+g+"/jquery.min.js";c.onload=c.onreadystatechange=function(){if(!b&&(!(d=this.readyState)||d=="loaded"||d=="complete")){h((f=e.jQuery).noConflict(1),b=1);f(c).remove()}};a.documentElement.childNodes[0].appendChild(c)}})(window,document,"1.6",function($,L){var%20$checkBoxes=$("input:checkbox");$checkBoxes.prop("checked",!$checkBoxes.prop("checked"));});
<?php
// node/add/project-review/%nid
$nid = arg(3); //Gets the nid from the url
if ($nid) {
//get the project node
$node = node_load($nid);
//add the entity reference to the project of it does not already have one
if (empty($form['field_project_refence'][LANGUAGE_NONE][0]['target_id']['#default_value'])) {
$("input").focus(function() {
$(this).parent().addClass("add-bg");
}).blur(function(){
$(this).parent().removeClass("add-bg");
});
@segovia94
segovia94 / SingularityGS-layout-output.css
Last active August 29, 2015 14:06
Basic 3 column layout with SingularityGS. Generated by SassMeister.com.
*, *:before, *:after {
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
img, video {
max-width: 100%;
height: auto;
}
@segovia94
segovia94 / gist:ee46a6e4670337316483
Created October 6, 2014 18:00
Hide menu on off click
//http://css-tricks.com/dangers-stopping-event-propagation/
$(document).click(function(event) {
if (!$(event.target).closest('.menucontainer').length) {
// Hide the menus.
console.log('hide the menu');
}
});
@segovia94
segovia94 / Print Drupal Permissions
Created January 27, 2015 01:25
Get a list of Drupal permissions
<?php
// Print a list of all set permissions.
// You can then copy the output from the website source code and paste it into a php array.
$user_roles = user_roles();
$roles = user_role_permissions($user_roles);
foreach ($roles as $rid => $permissions) {
print "\n\n" . $user_roles[$rid] . "\n";
foreach ($permissions as $permission => $bool) {
print "'" . $permission . "',\n";
@segovia94
segovia94 / gist:5ddd6df0d799e2e9f032
Last active August 29, 2015 14:15
Add ckeditor autosave plugin to drupal ckeditor module
<?php
// Create a "plugins" directory in the gs_wysiwyg module and add the ckeditor autosave plugin to it.
// Then add the following code into the gs_wysiwyg.module file
/**
* Implements hook_ckeditor_plugin().
*/
function gs_wysiwyg_ckeditor_plugin() {
$plugin_path = drupal_get_path('module', 'gs_wysiwyg') . '/plugins/';
//force IE to render in latest version or use Google chrome
$meta_edge = array(
'#type' => 'html_tag',
'#tag' => 'meta',
'#attributes' => array(
'http-equiv' => 'X-UA-Compatible',
'content' => 'IE=edge,chrome=1',
)
);
@segovia94
segovia94 / SassMeister-input-HTML.html
Created June 30, 2015 18:47
Generated by SassMeister.com.
<main>
<div class="detail">
<h2>Hey Johnnie!</h2>
<p>The untold legend</p>
</div>
<div class="detail2">test</div>
</main>
<section>
<h2>Mom said it all</h2>