Skip to content

Instantly share code, notes, and snippets.

@nerdy-sam
nerdy-sam / arraySwap.js
Created February 5, 2012 04:58
Swap keys for values in javascript array
// Swaps array values with keys.
// keep this comment to reuse freely: http://www.fullposter.com/?1
// If 2nd argument passed, values become keys,
// but keys do NOT become values: ALL values become second argument
function arraySwap(array,overwriteNewValue,keepKey){if(typeof(array)=="undefined"){return false;};if(typeof(array)!="object"){array=new Array(array);};var output=new Array();if(typeof(overwriteNewValue)=="undefined"){for(var k in array){output[array[k]]=k;}}else{if(!keepKey){for(var k in array){output[array[k]]=overwriteNewValue;}}else{for(var k in array){output[k]=overwriteNewValue;}};}return output;}
@mankyKitty
mankyKitty / ViewsHandlersShakedown.md
Last active October 27, 2021 05:32
This is a cheat sheet for information about extending the capabilities of Views by extending and building your own handlers. It will cover the basic handlers and attempt to cover some of the hooks that you might use when doing so. Including examples, basic documentation and some caveats where necessary.THIS IS NOT A COMPLETE LIST!! Consider the …

#Views Handlers - A Shakedown

This is a cheat sheet for information about extending the capabilities of Views by extending and building your own handlers. It will cover the basic handlers and attempt to cover some of the hooks that you might use when doing so. Including examples, basic documentation and some caveats where necessary. THIS IS NOT A COMPLETE LIST!! Consider the code of the handler your looking to extend to be the ultimate source of documentation. This is merely a convenience and a starting point.

_Ignore the tags in the included snippets, they are a convenience for formatting.

Extending / Including Your Handler

  • Determine which handler you're going to extend. (eg views_handler_field_numeric).
  • Create a PHP .inc file using the class name of your handler: views_handler_field_my_numeric_field.inc.