Dave Reid

Code

  1. // Find all nodes that have an entity reference field value of user #5.
  2.  
  3. $query = new EntityFieldQuery();
  4. $query->entityCondition('entity_type', 'node');
  5. $query->propertyCondition('status', 1);
  6. $

Code

  1. /**
  2.  * The point of this code is so that I can make an array of objects and can easily output a string representation of each object but retain the full data.
  3.  *
  4.  * For example:
  5.  * $terms = taxono

Code

  1. /**
  2.  * Implements hook_node_view_alter().
  3.  */
  4. function custom_node_view_alter(&$build) {
  5.   $node = $build['#node'];
  6.   if ($node->type == 'event' && ($data = _custom_event_view_node_get_data()) &&

Code

  1. /**
  2.  * Form builder to add or edit an URL redirect.
  3.  *
  4.  * @see redirect_element_validate_source()
  5.  * @see redirect_element_validate_redirect()
  6.  * @see redirect_edit_form_validate()
  7.  * @see redir

Fix for Code

  1. function mymodule_page_build(&$page) {
  2.   if (!isset($page['content']['system_main']['actions'])) {
  3.     $page['content']['system_main']['actions'] = array(
  4.       '#theme' => 'links',
  5.       '#links'

Code

  1.     $page['content']['system_main']['actions'] = array(
  2.       '#theme' => 'links',
  3.       '#links' => $actions,
  4.       '#attributes' => array('class' => array('action-links')),
  5.       '#weight' => -1

Code

  1. // settings.php:
  2.  
  3. <?php
  4. ...
  5. $databases['default']['default'] = array(
  6.   'driver' => 'mysql',
  7.   'database' => 'databasename',
  8.   'username' => 'username',
  9.   'password' => 'password',
  10.   'host' =

Fix for Fix for Code

  1.   if (isset($variables['page']['content']['system_main']['nodes'])) {
  2.     if ($nids = element_children($variables['page']['content']['system_main']['nodes'])) {
  3.       $first_nid = reset($nids);
  4.    

Fix for Code

  1. template_preprocess_page(&$variables) {
  2.   if (!empty($variables['page']['content']['system_main']['nodes'])) {
  3.     $first_node = reset($variables['page']['content']['system_main']['nodes']);
  4.     $f

Code

  1. template_preprocess_page(&$variables) {
  2.   foreach (array_keys($variables['page']['content']['system_main']['nodes']) as $nid) {
  3.     $variables['page']['content']['system_main']['nodes'][$nid]['#node

Supporting bundles for taxonomy terms in EntityFieldQuery

  1. function mymodule_taxonomy_entity_query_alter($query) {
  2.   $conditions = &$query->entityConditions;
  3.  
  4.   // Alter taxonomy term queries only.
  5.   if (isset($conditions['entity_type']) && $conditions['e

Fix for Code

  1. $node->nid = NULL; // or '0' or some value here to account for new nodes.
  2. _pathauto_include();
  3. $placeholders = pathauto_get_placeholders('node', $node);
  4. $pathauto_alias = pathauto_create_alias('nod

Code

  1. $node->nid = NULL; // or '0' or some value here to account for new nodes.
  2. module_load_include('inc', 'pathauto');
  3. $pathauto_alias = pathauto_create_alias('node', 'return', "node/{$node->nid}", array

Code

  1. $field1_instance = field_info_instance('user', 'field_fieldname1', 'user');
  2. if ($field1_items = field_get_items('user', $account, 'field_fieldname1')) {
  3.   $text = _text_sanitize('user', LANGUAGE_NON

entity_access

  1. function entity_access($entity_type, $entity, $op, $account = NULL) {
  2.   $rights = &drupal_static(__FUNCTION__, array());
  3.  
  4.   if (empty($entity) || !in_array($op, array('view', 'update', 'delete', 'c

entity meta tag description field

  1. function custom_entity_view($entity, $type, $view_mode, $langcode) {
  2.   if ($view_mode == 'full' && $items = field_get_items($type, $entity, 'field_meta_description', $langcode)) {
  3.     $description_t

node meta tag description field

  1. function custom_node_view($node, $view_mode, $langcode) {
  2.   if (node_is_page($node) && $items = field_get_items('node', $node, 'field_meta_description')) {
  3.     $description_tag = array(
  4.       '#typ

git-pull-all.sh

  1. #!/bin/sh
  2. SCRIPT_DIR=`pwd`
  3.  
  4. for dir in $(find . -type d -name .git)
  5. do
  6.   cd "$SCRIPT_DIR/$dir/.."
  7.   echo "git pull `pwd`"
  8.   git pull
  9. done

Code

  1. function _token_field_attach_view($entity_type, $entity, $field_name, $index = NULL, array $options = array()) {
  2.   $view_mode = 'token';
  3.   list($id, $vid, $bundle) = entity_extract_ids($entity_type,

Code

  1. class sshkey_handler_field_sshkey_link_edit extends views_handler_field {
  2.   function construct() {
  3.     parent::construct();
  4.     $this->additional_fields['key_id'] = 'key_id';
  5.   }
  6.  
  7.   function opt
Syndicate content