Edit

Nodes

Items

112

Per Page

/ 6

Subject Attribute

  • Using jQuery flexslider with animated captions callback

    Context: 
    Connection: 
    Attribute Type: 
    Types
    Connection: 
    Weight: 
    100
    Attribute Type: 
    Topics
    jQuery(window).load(function(){
    
    
    
        jQuery('.flexslider').flexslider( {
    
            pauseOnHover: true,
            controlsContainer: ".flex-container",
        	slideshowSpeed: 8000,
    
            before: function(slider){
                var currentSlide = slider.slides.eq(slider.currentSlide);
                jQuery(currentSlide).find('.flex-caption').animate({'opacity':'0','right':'30px'},700);
            },
            after: function(slider){
                var currentSlide = slider.slides.eq(slider.currentSlide);
                jQuery(currentSlide).find('.flex-caption').animate({'opacity':'1','right':'0'},700);
            },
            start: function(slider){
                var currentSlide = slider.slides.eq(slider.currentSlide);
                jQuery(currentSlide).find('.flex-caption').animate({'opacity':'1','right':'0'},700);
            },
    
        } );
    
    
    
    } );
    .flex-container .flexslider ul.slides li a p.flex-caption{
        background-color: rgba(255,255,255,.9);
        color: rgba(55,55,55,.98);
        font-size: 20px;
        position: absolute;
        bottom: 0;
        right: 0;
        right: 30px;
        left: auto;
        z-index: 1;
        padding: 15px;
        width: 33.3%;
        font-style: italic;
        margin: 0;
        opacity: 0;
    }
  • Topics

    Context: 
    Connection: 
    Attribute Type: 
    Types
    Connection: 
    Attribute Type: 
    Types
    Connection: 
    Attribute Type: 
    Types
    Images: 
  • MySQL

    Context: 
    Connection: 
    Attribute Type: 
    Types
    Connection: 
    Weight: 
    100
    Attribute Type: 
    Topics
    Weight: 
    45
    Attribute Type: 
    Topics
  • Removes fields pending for deletion to uninstall a stuck module

    Context: 
    Connection: 
    Weight: 
    100
    Attribute Type: 
    Topics
    Connection: 
    Weight: 
    100
    Attribute Type: 
    Topics
    DELETE FROM `field_config` WHERE `field_config`.`deleted` = 1;
  • Reading/setting Drupal config variables

    Context: 
    Connection: 
    Attribute Type: 
    Types
    Connection: 
    Weight: 
    100
    Attribute Type: 
    Topics
    <?php
    function organic_context_config_page(){
        $form = array();
        $form['onthisdate_maxdisp'] = array(
            '#type' => 'textfield',
            '#title' => t('Maximum number of links'),
            '#default_value' => variable_get('onthisdate_maxdisp', 3),
            '#size' => 2,
            '#maxlength' => 2,
            '#description' => t("The maximum number of links to display in the block."),
            '#required' => TRUE,
        );
        return system_settings_form($form);
    }
    ?>
  • Migrates multigroups in D6 to field collections in D7

    Context: 
    Connection: 
    Attribute Type: 
    Types
    Connection: 
    Weight: 
    100
    Attribute Type: 
    Topics
    <?php
    
    /////////////////// PAGE DEFINITIONS ///////////////////
    
    
    function migrate_groups_menu(){
        $menu["migrate_groups"] = array(
            "title" => "Migrate grps",
            "description" => "....",
            "page callback" => "migrate_multigroup_to_collections",
            "access callback" => TRUE,
        );
        return $menu;
    }
    
    
    
    /*function migrate_multigroup_to_collections() {
      $content_type = 'thing';
      $collection_field = 'field_context';
      $multigroup_fields = array(
        'field_connection',
        'field_title_in_context',
      );
    
      // Get all the nodes that have value in the multigroup.
      $query = db_select('field_data_' . $multigroup_fields[0])
        ->condition('entity_type', 'node')
        ->condition('bundle', $content_type);
      $query->addExpression('DISTINCT entity_id', 'nid');
      $query->addExpression('revision_id', 'vid');
      $nodes_result = $query->execute();
    
      foreach ($nodes_result as $node) {
        // Construct the legacy multigroup for the node from the individual fields.
        $multigroup_data = array();
        foreach ($multigroup_fields as $field) {
          $field_result = db_select('field_data_' . $field, 'field')
            ->fields('field')
            ->condition('entity_type', 'node')
            ->condition('entity_id', $node->nid)
            ->execute();
    
          foreach ($field_result as $field_item) {
            $multigroup_data[$field_item->delta][$field] = $field_item;
          }
    
        }
    
        // Step through the reconstructed multigroups, which are collections from now.
        foreach ($multigroup_data as $delta => $data) {
          // Create entry in field_collection_item table.
          $id = db_insert('field_collection_item')
            ->fields(array('field_name' => $collection_field))
            ->execute();
    
          // Attach collection field data to the node.
          db_insert('field_data_' . $collection_field)
            ->fields(array(
              'entity_type' => 'node',
              'bundle' => $content_type,
              'entity_id' => $node->nid,
              'revision_id' => $node->vid,
              'language' => 'und',
              'delta' => $delta,
              $collection_field . '_value' => $id,
            ))
            ->execute();
    
          // Go through all the fields in the multigroup.
          foreach ($data as $multigroup_field => $field_data) {
            // Reassign the fields in the multigroup from the node to the collection field instance.
            db_update('field_data_' . $multigroup_field)
              ->fields(array(
                'entity_type' => 'field_collection_item',
                'bundle' => $collection_field,
                'entity_id' => $id,
                'revision_id' => $id,
                'delta' => 0,
              ))
              ->condition('entity_type', 'node')
              ->condition('entity_id', $node->nid)
              ->condition('delta', $delta)
              ->execute();
    
          }
        }
      }
      return "FINISHED";
    }*/
    
    
    
    function migrate_multigroup_to_collections($content_type='page',$collection_field='field_context',$multigroup_fields=array('field_connection','field_weight','field_notes')) {
    
      // Get all the nodes that have value in the multigroup.
      $query = db_select('field_data_' . $multigroup_fields[0])
        ->condition('entity_type', 'node')
        ->condition('bundle', $content_type);
      $query->addExpression('DISTINCT entity_id', 'nid');
      $query->addExpression('revision_id', 'vid');
      $nodes_result = $query->execute();
    
      foreach ($nodes_result as $node) {
        // Construct the legacy multigroup for the node from the individual fields.
        $multigroup_data = array();
        foreach ($multigroup_fields as $field) {
          $field_result = db_select('field_data_' . $field, 'field')
            ->fields('field')
            ->condition('entity_type', 'node')
            ->condition('entity_id', $node->nid)
            ->execute();
    
          foreach ($field_result as $field_item) {
            $multigroup_data[$field_item->delta][$field] = $field_item;
          }
    
        }
    
        $id = 0;
        // Step through the reconstructed multigroups, which are collections from now.
        foreach ($multigroup_data as $delta => $data) {
          // Create entry in field_collection_item table.
          $id = db_insert('field_collection_item')
            ->fields(array('field_name' => $collection_field, 'revision_id' => 0, 'archived' => 0))
            ->execute();
    
          $revid = db_insert('field_collection_item_revision')
            ->fields(array('item_id' => $id))
            ->execute();
    
          db_update('field_collection_item')
              ->fields(array('revision_id' => $revid))
              ->condition('item_id', $id)
              ->execute();
    
    
          // Attach collection field data to the node.
          db_insert('field_data_' . $collection_field)
            ->fields(array(
              'entity_type' => 'node',
              'bundle' => $content_type,
              'entity_id' => $node->nid,
              'revision_id' => $node->vid,
              'language' => 'und',
              'delta' => $delta,
              $collection_field . '_value' => $id,
              $collection_field . '_revision_id' => $revid,
            ))
            ->execute();
    
          // Attach collection field data to the node.
          db_insert('field_revision_' . $collection_field)
            ->fields(array(
              'entity_type' => 'node',
              'bundle' => $content_type,
              'entity_id' => $node->nid,
              'revision_id' => $node->vid,
              'language' => 'und',
              'delta' => $delta,
              $collection_field . '_value' => $id,
              $collection_field . '_revision_id' => $revid,
            ))
            ->execute();
    
          // Go through all the fields in the multigroup.
          foreach ($data as $multigroup_field => $field_data) {
            // Reassign the fields in the multigroup from the node to the collection field instance.
            db_update('field_data_' . $multigroup_field)
              ->fields(array(
                'entity_type' => 'field_collection_item',
                'bundle' => $collection_field,
                'entity_id' => $id,
                'language' => 'und',
                'revision_id' => $revid,
                'delta' => 0,
              ))
              ->condition('entity_type', 'node')
              ->condition('entity_id', $node->nid)
              ->condition('delta', $delta)
              ->execute();
    
           db_delete('field_revision_' . $multigroup_field)
              ->condition('entity_type', 'node')
              ->condition('entity_id', $node->nid)
            ->execute();
          $qry = "INSERT INTO field_revision_$multigroup_field SELECT * FROM field_data_$multigroup_field WHERE entity_id = $id AND entity_type = 'field_collection_item' AND bundle = '$collection_field'";
          db_query($qry);
    
          }
        }
      }
      return "DONE";
    }
    
    ?>
  • Google

    Context: 
    Connection: 
    Weight: 
    100
    Attribute Type: 
    Topics
    Connection: 
    Attribute Type: 
    Types
  • Organic Connectivity Module

    Context: 
    Connection: 
    Attribute Type: 
    Types
    Connection: 
    Attribute Type: 
    Types
    Connection: 
    Weight: 
    45
    Attribute Type: 
    Topics
    Connection: 
    Weight: 
    45
    Attribute Type: 
    Topics
    Connection: 
    Weight: 
    30
    Attribute Type: 
    Content Strategy
    Installation URL: 
    http://connectivity.orgnsm.org
    Images: 
  • Drupal DB Query to find Children (Recursively)

    Context: 
    Connection: 
    Attribute Type: 
    Types
    Connection: 
    Weight: 
    100
    Attribute Type: 
    Topics
    Connection: 
    Weight: 
    100
    Attribute Type: 
    Topics
    Connection: 
    Weight: 
    100
    Attribute Type: 
    Topics
    <?php
    function loadchildrens($context){
    	$sql_children = "SELECT node.nid AS nid,
       node.vid AS node_vid,
       node.title AS node_title
     FROM node node 
     LEFT JOIN content_field_connection node_data_field_connection ON node.vid = node_data_field_connection.vid
     WHERE (node.type in ('category')) AND (node_data_field_connection.field_connection_nid = ".$context.")
       ORDER BY node_title ASC";
    
    	$db_query_children = db_query( $sql_children );
    
    	while( $row = db_fetch_array($db_query_children) ){
    		$context_tree[ $row["nid"] ] = array();
    		if( $row["nid"] != "517" )
    			$context_tree[ $row["nid"] ] = loadchildrens( $row["nid"] );
    	}
    	return $context_tree;
    }
    ?>
    <?php
    
    $node = node_load(arg(1));
    
    $spheres_via_path = array();
    
    $sql_spheres_via_project = "SELECT node.title AS node_title, node.nid AS nid, node.type AS node_type
    FROM {node} node
    LEFT JOIN {field_data_field_project} field_data_field_project ON node.nid = field_data_field_project.entity_id
    WHERE (node.type in ('note')) AND (field_data_field_project.field_project_nid = '".arg(1)."')";
    
    $db_query_spheres_via_project = db_query( $sql_spheres_via_project );
    
    if( $db_query_spheres_via_project->rowCount() ){
    	$return = "<h3>Notes</h3>\n";
    	$return .= "<ul>\n";
    	foreach( $db_query_spheres_via_project as $sphere ){
    		if( isset($sphere->nid) ) $spheres_via_project[ $sphere->nid ] = $sphere;
    		$return .= "<li><a href=\"/node/".$sphere->nid."\">".$sphere->node_title."</a></li>\n";
    	}
    	$return .= "</ul>\n";
        return $return;
    }
    
    return '<div><strong>Associated Notes:</strong></div>';
    ?>
        // Obtain sphere nodes
        $query=new EntityFieldQuery();
        $query->entityCondition('entity_type','node')
              ->entityCondition('bundle','sphere');
        $sephiroths=$query->execute();
        if(array_key_exists('node',$sephiroths))
            $sephiroths=entity_load('node',array_keys($sephiroths['node']));
    
    
        // Obtain path nodes
        $query=new EntityFieldQuery();
        $query->entityCondition('entity_type','node')
              ->entityCondition('bundle','path');
        $paths=$query->execute();
        if(array_key_exists('node',$paths))
            $paths=entity_load('node',array_keys($paths['node']));
    
  • Similar by Taxonomy

    Context: 
    Connection: 
    Attribute Type: 
    Types
    Connection: 
    Weight: 
    100
    Attribute Type: 
    Topics
    Connection: 
    Weight: 
    100
    Attribute Type: 
    Topics
    <ul class="item-list">
    <?php
    
    $terms_nood = taxonomy_node_get_terms_by_vocabulary($node,6);
    
    $terms = taxonomy_get_tree(6);
    
    foreach($terms as $term){
    
    	//$tagged = taxonomy_term_count_nodes($term->tid);
    
    	if( $term->name == arg(1) || array_key_exists( $term->tid,$terms_nood ) ){
    		echo("<li class=\"collapsed tag-category-".$popularityCategory."\">");
    		echo("<a href=\"/visual/".$term->name."\" class=\"active\">".$term->name."</a>");
    		echo("</li>\n");
    	}
    
    }
    
    ?>
    </ul>
    
    
    <?php
    if(arg(0)=='node'&&isset($node)){
        $vocabularies = taxonomy_get_vocabularies();
        foreach( $vocabularies as $vocabulary ){
            if( $vocabularies ){
                $terms = taxonomy_node_get_terms_by_vocabulary($node,$vocabulary->vid);
                if( $terms ){
                    echo('<div>');
                    $links = array();
                    echo('<h3>' . $vocabulary->name . '</h3>');
                    foreach( $terms as $term ){
                        $term_uri = taxonomy_term_uri($term);
                        $links[] = l($term->name,$term_uri['path'],array('rel'=>'tag','title'=>strip_tags($term->description)));
                    }
                    echo(implode(', ', $links));
                    echo('</div>');
                }
            }
        }
    }
    ?>
    
    
    <?php #if ($terms): ?>
    <?php
    $vocabularies = taxonomy_get_vocabularies();
    foreach( $vocabularies as $vocabulary ){
    	if( $vocabularies ){
    		$terms = taxonomy_node_get_terms_by_vocabulary($node, $vocabulary->vid);
    		if( $terms ){
    			echo("<div>\n");
    			$links = array();
    			echo( "<h3>" . $vocabulary->name . "</h3>\n" );
    			foreach( $terms as $term )
    				$links[] = l($term->name, taxonomy_term_path($term), array('rel' => 'tag', 'title' => strip_tags($term->description)));
    			echo( implode(', ', $links) );
    			echo("</div>\n");
    		}
    	}
    }
    ?>
  • Wordpress

    Context: 
    Connection: 
    Attribute Type: 
    Types
    Connection: 
    Attribute Type: 
    Types
    Connection: 
    Weight: 
    100
    Attribute Type: 
    Topics
    Images: 
  • Rename stuck field names

    Context: 
    Connection: 
    Attribute Type: 
    Types
    Connection: 
    Weight: 
    100
    Attribute Type: 
    Topics
    Connection: 
    Weight: 
    100
    Attribute Type: 
    Topics
    <?php
    
    $fields = array(
        'field_inspirational_imagery' => 'field_images',
    );
     
    // Loop through each of the fields/tables with the old name and change them
    foreach($fields as $field_name => $new_field_name) {
     
        // First check that field_name exists
        if(!db_table_exists('field_data_' . $field_name)) {
            // If we cannot find a data table then just continue.
            continue;
        }
     
        // Define some things...
        $data_table_name = 'field_data_' . $field_name;
        $revision_table_name = 'field_revision_' . $field_name;
        $field_info = field_info_field($field_name);
        $storage_details = $field_info['storage']['details'];
     
        // The storage for each field has unique configuration. Must follow.
        foreach($storage_details['sql']['FIELD_LOAD_CURRENT'] as $field) {
            // Change the field names.
            foreach($field as $key => $value) {
     
                // Rename the field table columns and preserve existing spec. Let
                // features take care of any configuration changes.
                $spec = $field_info['columns'][$key];
                db_change_field($data_table_name, $value, $new_field_name . "_" . $key, $spec);
                db_change_field($revision_table_name, $value, $new_field_name . "_" . $key, $spec);
     
            }
        }
     
        // Change the field storage table names.
        db_rename_table($data_table_name, 'field_data_' . $new_field_name);
        db_rename_table($revision_table_name, 'field_revision_' . $new_field_name);
     
        // Change the field names int he field_config and
        // field_instance_config tables
     
        db_update('field_config')
            ->fields(
                array(
                    'field_name' => $new_field_name,
                )
            )
            ->condition('field_name', $field_name, '=')
        ->execute();
     
        db_update('field_config_instance')
            ->fields(
                array(
                    'field_name' => $new_field_name,
                )
            )
            ->condition('field_name', $field_name, '=')
        ->execute();
    
    } /// end foreach loop on fields... whew.
    
    ?>
  • OSX Virtual Web Host Config

    Context: 
    Connection: 
    Attribute Type: 
    Types
    Connection: 
    Weight: 
    100
    Attribute Type: 
    Topics

    add line to /etc/hosts

    127.0.0.1 amniot.localhost

    add lines to /etc/apache2/httpd.conf

    NameVirtualHost 127.0.0.1:80
    
    <VirtualHost amniot.localhost:80>
    
    <Directory "/Library/Webserver/Documents_AMNIOT">
        Options FollowSymLinks Indexes
        AllowOverride All
        Order deny,allow
        allow from All
    </Directory>
    ServerName amniot.localhost
    DocumentRoot "/Library/Webserver/Documents_AMNIOT"
    
    </VirtualHost>
  • MySQL Basics

    Context: 
    Connection: 
    Attribute Type: 
    Types

    add export PATH=$PATH:/usr/local/mysql/bin to ~/.bash_profile or /etc/profile

    Backup database to text file

    mysqldump database_name > database_name.sql

    Remove database

    mysql> drop database database_name;

    Create database

    mysql> CREATE DATABASE database_name;
  • Manually reset Drupal admin password

    Context: 
    Connection: 
    Attribute Type: 
    Types
    Connection: 
    Weight: 
    100
    Attribute Type: 
    Topics
    Connection: 
    Weight: 
    45
    Attribute Type: 
    Topics
    <?php
    define('DRUPAL_ROOT', getcwd());
    require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
    drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
    require_once DRUPAL_ROOT . '/includes/password.inc';
    if (isset($_GET['pass']) && !empty($_GET['pass'])) {
      $newhash =  user_hash_password($_GET['pass']);
    }
    else {
      die('Retry with ?pass=PASSWORD set in the URL');
    }
    $updatepass = db_update('users')
      ->fields(array(
        'pass' => $newhash,
    // Uncomment the following lines to reset the administrative username and/or email address, if necessary.
    //    'name' => 'admin',
    //    'mail' => 'yourmail@example.com'
      ))
      ->condition('uid', '1', '=')
      ->execute();
    print "Done. Please delete this file immediately!";
    drupal_exit();
    ?>
  • PHP

    Context: 
    Connection: 
    Weight: 
    100
    Attribute Type: 
    Topics
    Connection: 
    Attribute Type: 
    Types
    Connection: 
    Weight: 
    45
    Attribute Type: 
    Topics
    Images: 
  • JQuery

    Context: 
    Connection: 
    Weight: 
    100
    Attribute Type: 
    Topics
    Connection: 
    Attribute Type: 
    Types
    Connection: 
    Weight: 
    45
    Attribute Type: 
    Topics
    Images: 
  • Nested-query approach to mining field_collection data and relationship

    Context: 
    Connection: 
    Attribute Type: 
    Types
    Connection: 
    Weight: 
    100
    Attribute Type: 
    Topics
    Connection: 
    Weight: 
    100
    Attribute Type: 
    Topics
    <?php
    
    function get_species_country($id_country) {
        $inner = new EntityFieldQuery();
        $inner_r = $inner->entityCondition('entity_type', 'field_collection_item')
                         ->fieldCondition('field_species_country', 'target_id', $id_country, '=')
                         ->execute();
        if(!empty($inner_r['field_collection_item'])) {
            $keys = array_keys($inner_r['field_collection_item']);
            $query = new EntityFieldQuery();
            $species_r = $query->entityCondition('entity_type', 'node')
                          ->entityCondition('bundle', self::$bundle)
                          ->fieldCondition('field_species_countries', 'value', $keys)
                          ->execute();
            if(!empty($species_r['node'])) {
                $ret = node_load_multiple(array_keys($species_r['node']));
            }
        }
        return $ret;
    }
    
    ?>
  • Create symlinks

    Context: 
    Connection: 
    Attribute Type: 
    Types
    Weight: 
    100
    Attribute Type: 
    Topics
    Connection: 
    Weight: 
    100
    Attribute Type: 
    Topics
    <?php
    
    symlink('/homepages/21/d93015512/htdocs/library/organic_connectivity',
            '/homepages/21/d93015512/htdocs/drupal/sites/all/modules/organic_connectivity/lib');
    
    ?>
  • Trauma Informed Care

    Subtitle: 
    Information &amp; Blog
    Context: 
    Connection: 
    Weight: 
    100
    Attribute Type: 
    Topics
    Connection: 
    Weight: 
    100
    Attribute Type: 
    Topics
    Connection: 
    Attribute Type: 
    Types
    Connection: 
    Weight: 
    100
    Attribute Type: 
    Topics
    Installation URL: 
    http://www.traumainformedhawaii.net
    Images: