This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Implements hook_views_query_alter(). | |
* | |
* By default, views will make sort criteria take precedence over views table sorts when | |
* "Override normal sorting if click sorting is used" is unticked. This is not ideal when | |
* you want the user initiated sorting to be secondary sorted on another column. | |
*/ | |
function hook_views_query_alter(&$view, &$query) { | |
// Reverse the query order. Note if you have more than one sort criteria, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Implements hook_query_alter(). | |
* | |
* This hook will make it so your Drupal views are filtered by unique on a single field value. | |
* | |
* Make sure to tag your views query first by going to 'Query Settings: settings' configuration | |
* in Views UI and, under 'Query Tags', adding 'MY_AWESOME_TAG' or whatever you're using.' | |
*/ | |
function hook_query_alter(QueryAlterableInterface $query) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Give admin role permissions to all modules on site. | |
*/ | |
function my_custom_module_update_7001() { | |
$permissions = array(); | |
foreach (module_implements('permission') as $module) { | |
$module_permissions = module_invoke($module, 'permission'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Paste this into your console. | |
// Change 'rid' variable value to be the role id you are modifying. | |
var rid = 3; jQuery('input.rid-' + rid).prop('checked', true); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Define the model. | |
class Comment extends Backbone.Model | |
# Create a new instance of the model. | |
comment = new Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Define the model. | |
class Comment extends Backbone.Model | |
defaults: | |
name: 'test' | |
email: '[email protected]' | |
body: 'BODY' | |
# Create a new instance of the model. | |
comment = new Comment | |
name: 'Overriden name' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Define the collection. | |
class CommentCollection extends Backbone.Collection | |
model: Comment | |
# Create a new instance of the collection. | |
comments = new CommentCollection | |
# Add a few comments to the collection. | |
collection.add [ | |
{name: 'Comment 1'}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Define the model. | |
class Comment extends Backbone.Model | |
defaults: | |
name: 'test' | |
email: '[email protected]' | |
body: 'BODY' | |
# Define the collection. | |
class CommentCollection extends Backbone.Collection | |
model: Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class @Person | |
firstName: 'John' | |
lastName: 'Doe' | |
constructor: (@firstName, @lastName) -> | |
fullName: -> | |
return "#{@firstName} #{@lastName}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
QUnit.module 'Person class' | |
test 'Full name is printed correctly', -> | |
person = new Person('James', 'Bond') | |
equal 'James Bond', do person.fullName, 'Full name was printed correctly' |
OlderNewer