Edit

Error message

  • Notice: Undefined offset: 37 in include() (line 133 of /homepages/21/d93015512/htdocs/library/organic_connectivity/items_table.tpl.php).
  • Notice: Trying to get property 'title' of non-object in include() (line 133 of /homepages/21/d93015512/htdocs/library/organic_connectivity/items_table.tpl.php).
  • Notice: Undefined variable: monthCounts in include() (line 12 of /homepages/21/d93015512/htdocs/library/organic_connectivity/date_overview.tpl.php).
  • Notice: Trying to access array offset on value of type null in include() (line 12 of /homepages/21/d93015512/htdocs/library/organic_connectivity/date_overview.tpl.php).
  • Notice: Undefined variable: monthCounts in include() (line 14 of /homepages/21/d93015512/htdocs/library/organic_connectivity/date_overview.tpl.php).
  • Warning: array_reverse() expects parameter 1 to be array, null given in include() (line 14 of /homepages/21/d93015512/htdocs/library/organic_connectivity/date_overview.tpl.php).
  • Warning: Invalid argument supplied for foreach() in include() (line 21 of /homepages/21/d93015512/htdocs/library/organic_connectivity/date_overview.tpl.php).

Items

Per Page

/ 3

Subject Attribute

Nodes Posts Things

Blocks

items_blocks.tpl.php

Nodes

items_nodes.tpl.php

  • Macintosh

    Context: 
    Connection: 
    Attribute Type: 
    Types
    Connection: 
    Attribute Type: 
    Types
    Connection: 
    Weight: 
    100
    Attribute Type: 
    Topics
  • see what is accessing disk / force unmount disk

    Context: 
    Connection: 
    Attribute Type: 
    Types
    Connection: 
    Weight: 
    100
    Attribute Type: 
    Topics
    lsof | grep /Volumes/IMAJIN
    
    
    
    
    diskutil unmountDisk force /Volumes/IMAJIN
  • Find which file a function is defined in

    Subtitle: 
    Context: 
    Connection: 
    Attribute Type: 
    Types
    Connection: 
    Weight: 
    100
    Attribute Type: 
    Topics
    Installation URL: 
    Notes: 
    <?php
    
    $reflFunc=new ReflectionFunction('name_of_function');
    
    echo($reflFunc->getFileName().':'.$reflFunc->getStartLine());
    
    ?>
  • Custom Post Types

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

    Adds custom post type called "Reviews"

    <?php
    function create_post_type(){
      register_post_type('review',
        array(
          'labels'=>array(
            'name'=>__('Reviews'),
            'singular_name'=>__('Review')
          ),
          'public'=>true,
          'has_archive'=>true,
          'capabilities'=>array(
              'edit_post'=>'edit_review',
              'edit_posts'=>'edit_reviews',
              'publish_posts'=>'publish_review',
              'read_post'=>'read_review',
          ),
        )
      );
    }
    add_action('init','create_post_type');
    ?>

    Add abilities to "Reviews" post type

    <?php
    function add_theme_caps(){
        $subscribers=get_role('subscriber');
        $subscribers->add_cap('edit_review');
        $subscribers->add_cap('edit_reviews');
        $subscribers->add_cap('publish_review');
        $subscribers->add_cap('read_review');
        $admins=get_role('administrator');
        $admins->add_cap('edit_review');
        $admins->add_cap('edit_reviews');
        $admins->add_cap('publish_review');
        $admins->add_cap('read_review');
    }
    add_action('admin_init','add_theme_caps');
    ?>

    Add custom fields to "Reviews" post type

    <?php
    add_action('admin_init','add_review_metas');
    function add_review_metas(){
      add_meta_box('review_rating-meta','Rating','review_rating','review','normal','low');
    }
    function review_rating(){
      global $post;
      $custom=get_post_custom($post->ID);
      $review_rating=$custom['review_rating'][0];
        for($x=1;$x<6;$x++){
            echo('<input');
            if($x==$review_rating) echo(' checked="checked"');
            echo(' type="radio" name="review_rating" id="review_rating_'.$x.'" value="'.$x.'"/><label for="review_rating_'.$x.'">'.$x.'</label>'."\n");
    
        }
    }
    add_action('save_post','save_details');
    function save_details(){
      global $post;
      update_post_meta($post->ID,'review_rating',$_POST["review_rating"]);
    }
    ?>
  • In the Weeds

    Subtitle: 
    Restaurant Management Tool
    Context: 
    Connection: 
    Weight: 
    100
    Attribute Type: 
    Topics
    Connection: 
    Weight: 
    100
    Attribute Type: 
    Topics
    Connection: 
    Attribute Type: 
    Types
    Installation URL: 
    http://stage.orgnsm.org/in-the-weeds
    Images: 
  • Post referencing setup

    Subtitle: 
    Assign multiple disciplines to a project
    Context: 
    Connection: 
    Attribute Type: 
    Types
    Connection: 
    Weight: 
    100
    Attribute Type: 
    Topics
    <?php
    
    
    // Adds custom post type for Projects and Services
    
    function create_post_type(){
    
      register_post_type('project',
        array(
          'labels' => array(
            'name' => __('Projects'),
            'singular_name' => __('Project')
          ),
          'taxonomies' => array('category'),
          'public' => true,
          'has_archive' => true,
          'capabilities' => array(
              'edit_post' => 'edit_project',
              'edit_posts' => 'edit_projects',
              'publish_posts' => 'publish_project',
              'read_post' => 'read_project',
          ),
          'supports' => array(
              'title','editor','thumbnail'
          ),
        )
      );
    
      register_post_type('service',
        array(
          'labels' => array(
            'name' => __('Services'),
            'singular_name' => __('Service')
          ),
          'public' => true,
          'has_archive' => true,
          'capabilities' => array(
              'edit_post' => 'edit_service',
              'edit_posts' => 'edit_services',
              'publish_posts' => 'publish_service',
              'read_post' => 'read_service',
          ),
          'supports' => array(
              'title','editor','thumbnail'
          ),
        )
      );
    
    }
    
    add_action('init','create_post_type');
    
    
    
    
    
    function add_theme_caps(){
    
        $subscribers = get_role( 'subscriber' );
    
        //$subscribers->add_cap( 'edit_project' );
        //$subscribers->add_cap( 'edit_projects' );
        //$subscribers->add_cap( 'publish_project' );
    
        $subscribers->add_cap( 'read_project' );
        $subscribers->add_cap( 'read_service' );
    
        $admins = get_role( 'administrator' );
    
        $admins->add_cap( 'edit_project' );
        $admins->add_cap( 'edit_projects' );
        $admins->add_cap( 'publish_project' );
        $admins->add_cap( 'read_project' );
    
        $admins->add_cap( 'edit_service' );
        $admins->add_cap( 'edit_services' );
        $admins->add_cap( 'publish_service' );
        $admins->add_cap( 'read_service' );
    
    }
    
    add_action('init','add_theme_caps');
    
    
    
    
    
    // Adds custom field to the PROJECT custom post type
    
    function add_project_metas(){
        add_meta_box(
            'project_service-meta',
            'Service',
            'project_service',
            'project',
            'normal',
            'low'
        );
    }
    add_action('admin_init','add_project_metas');
    
    
    function project_service(){
        global $post;
        $custom=get_post_custom($post->ID);
        $project_services=$custom['project_service'][0];
        $project_services=unserialize($project_services);
        $args=array(
            'post_type'=>'service',
            'posts_per_page'=>'200',
            'orderby'=>'title',
            'order'=>'ASC'
        );
        $loop=new WP_Query($args);
        while($loop->have_posts()):$loop->the_post();
            echo('<div><input type="checkbox" name="project_services[]" value="'.get_the_ID().'" id="project_service_'.get_the_ID().'"');
            if(is_array($project_services)&&in_array(get_the_ID(),$project_services)) echo(' checked="checked"');
            //checked($project_services,get_the_ID());
            echo('><label for="project_service_'.get_the_ID().'">'.get_the_title(get_the_ID()).'</label></div>');
        endwhile;
    }
    
    
    
    function save_details(){
        global $post;
        update_post_meta($post->ID,'project_service',$_POST["project_services"]);
    }
    
    add_action('save_post','save_details');
    
    
    
    
    ?>
  • Covidien Portal

    Subtitle: 
    A resource and tool for physicians
    Context: 
    Connection: 
    Weight: 
    100
    Attribute Type: 
    Topics
    Connection: 
    Weight: 
    100
    Attribute Type: 
    Topics
    Weight: 
    100
    Attribute Type: 
    Topics
    Connection: 
    Weight: 
    100
    Attribute Type: 
    Topics
    Connection: 
    Attribute Type: 
    Types
    Connection: 
    Weight: 
    100
    Attribute Type: 
    Topics
    Installation URL: 
    http://covidien.orgnsm.org
    Images: 
  • Foster Care Training

    Subtitle: 
    Education Service Promotion
    Context: 
    Connection: 
    Attribute Type: 
    Types
    Connection: 
    Weight: 
    100
    Attribute Type: 
    Topics
    Connection: 
    Weight: 
    100
    Attribute Type: 
    Topics
    Installation URL: 
    http://fostercaretraining.org
    Images: 
  • AG &amp; Associates

    Subtitle: 
    Construction Portfolio &amp; Promotion
    Context: 
    Connection: 
    Attribute Type: 
    Types
    Connection: 
    Weight: 
    100
    Attribute Type: 
    Topics
    Connection: 
    Weight: 
    100
    Attribute Type: 
    Topics
    Connection: 
    Weight: 
    100
    Attribute Type: 
    Topics
    Installation URL: 
    http://agassociatesinc.com
    Images: 
  • Calvin Associates

    Subtitle: 
    Lawyer Firm Promotional
    Context: 
    Connection: 
    Attribute Type: 
    Types
    Connection: 
    Weight: 
    100
    Attribute Type: 
    Topics
    Connection: 
    Weight: 
    100
    Attribute Type: 
    Topics
    Installation URL: 
    http://calvin-associates.com
    Images: 
  • Ferber Law

    Subtitle: 
    Lawyer Firm Promotional
    Context: 
    Connection: 
    Attribute Type: 
    Types
    Connection: 
    Weight: 
    100
    Attribute Type: 
    Topics
    Connection: 
    Weight: 
    100
    Attribute Type: 
    Topics
    Installation URL: 
    http://danvillelaw.com
    Images: 
  • Oakland Police

    Subtitle: 
    Charity Information &amp; Donation
    Context: 
    Connection: 
    Attribute Type: 
    Types
    Connection: 
    Weight: 
    100
    Attribute Type: 
    Topics
    Connection: 
    Weight: 
    100
    Attribute Type: 
    Topics
    Installation URL: 
    http://oaklandpolicefoundation.org
    Images: 
  • Orgnsm (ROOT)

    Subtitle: 
    Community Outreach Divisions Catalog
    Context: 
    Connection: 
    Attribute Type: 
    Types
    Weight: 
    100
    Attribute Type: 
    Topics
    Connection: 
    Weight: 
    100
    Attribute Type: 
    Topics
    Connection: 
    Weight: 
    100
    Attribute Type: 
    Topics
    Connection: 
    Weight: 
    100
    Attribute Type: 
    Topics
    Installation URL: 
    http://orgnsm.org
    Images: 
    Process Imagery: 
  • Tru frame

    Subtitle: 
    Product promotion
    Context: 
    Connection: 
    Attribute Type: 
    Types
    Connection: 
    Weight: 
    100
    Attribute Type: 
    Topics
    Images: 
  • Lotto-rithm

    Subtitle: 
    Algorithm knowledge promotion
    Context: 
    Connection: 
    Attribute Type: 
    Types
    Connection: 
    Weight: 
    100
    Attribute Type: 
    Topics
    Images: 
  • Rate Your Customer / Rate My Contractor

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

    Subtitle: 
    my homepage
    Context: 
    Connection: 
    Attribute Type: 
    Types
    Connection: 
    Weight: 
    100
    Attribute Type: 
    Topics
    Connection: 
    Weight: 
    100
    Attribute Type: 
    Topics
    Connection: 
    Weight: 
    10
    Attribute Type: 
    Topics
    Weight: 
    100
    Attribute Type: 
    Topics
    Connection: 
    Weight: 
    100
    Attribute Type: 
    Topics
    Installation URL: 
    http://ixias.orgnsm.org
    Images: 
  • NeuroGenesix

    Subtitle: 
    Dance Music Event Information
    Context: 
    Connection: 
    Attribute Type: 
    Types
    Weight: 
    100
    Attribute Type: 
    Topics
    Connection: 
    Weight: 
    100
    Attribute Type: 
    Topics
    Connection: 
    Weight: 
    100
    Attribute Type: 
    Topics
    Connection: 
    Weight: 
    100
    Attribute Type: 
    Topics
    Installation URL: 
    http://neurogenesix.melanieblau.org
    Images: 
    Process Imagery: 
  • Font-embed Rundown

    Context: 
    Connection: 
    Attribute Type: 
    Types
    Connection: 
    Weight: 
    100
    Attribute Type: 
    Topics
    TTF - Works in most browsers except IE and iPhone
    EOT - IE only
    WOFF - Compressed, emerging standard
    SVG - iPhone/iPad
  • 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: 
  • Various WP snippets

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

    Show Links Menu w/Active Class

    <nav>
    <?php $args=array(
    	'sort_order' => 'ASC',
    	'sort_column' => 'post_date',
    	'hierarchical' => 1,
    	'exclude' => '',
    	'include' => '',
    	'meta_key' => '',
    	'meta_value' => '',
    	'authors' => '',
    	'child_of' => 0,
    	'parent' => -1,
    	'exclude_tree' => '',
    	'number' => '',
    	'offset' => 0,
    	'post_type' => 'page',
    	'post_status' => 'publish'
    );
    $pages = get_pages($args);
    $current_id = get_the_ID();
    if( $pages ){
        echo( "<ul>\n" );
        foreach( $pages as $page){
            $link_page_id = ($page->ID);
            if( $current_id==$link_page_id ) echo( "<li class=\"active\">" );
            else echo( "<li>" );
            echo( "<a href=\"".get_page_link($page->ID)."\">".$page->post_title."</a>" );
            echo( "</li>\n" );
        }
        echo( "</ul>\n\n" );
    }
    ?>
    </nav>

    Show Categories List

    <?php
        echo( "<div id=\"topics\">\n" );
        echo( "<h3>Topics</h3>\n" );
        echo( "<ul>\n" );
        $categories_obj = get_categories( array('orderby'=>'id','hide_empty'=>'1') );
        foreach( $categories_obj as $cat ){
            echo( "<li>" );
            echo( "<a href=\"/category/".$cat->slug."\">".$cat->name."</a>" );
            $posts_in_cat = new WP_Query( 'cat='.$cat->term_id );
            if ( $posts_in_cat->have_posts() ){
                echo( "<ul>\n" );
                while ( $posts_in_cat->have_posts() ){
                    $posts_in_cat->the_post();
                    echo( "<li><a href=\"");
                    the_permalink();
                    echo( "\">" );
                    the_title();
                    echo( "</a></li>\n" );
                }
                echo( "</ul>\n" );
            }
            echo( "</li>\n" );
        }
        echo( "</ul>\n" );
        echo( "</div>\n\n" );
    ?>

    Show Recent Posts List

    <?php
        echo( "<h2>What's New</h2>\n" );
        echo( "<ul>\n" );
        $latest_blog_posts = new WP_Query( array('posts_per_page'=>5) );
        if ( $latest_blog_posts->have_posts() ) :
            while ( $latest_blog_posts->have_posts() ) :
                $latest_blog_posts->the_post();
                // Loop output goes here
                echo( "<li><a href=\"");
                the_permalink();
                echo( "\">" );
                the_title();
                echo( "</a></li>\n" );
            endwhile;
        endif;
        echo( "</ul>\n" );
    }
    ?>

    Show Recent Posts Content

    <?php
        echo( "<?h2>Recent Posts<?/h2>\n" );
        $latest_blog_posts = new WP_Query( array( 'posts_per_page'=>5 ) );
        if ( $latest_blog_posts->have_posts() ){
            while ( $latest_blog_posts->have_posts() ){
                $latest_blog_posts->the_post();
                // Loop output goes here
                echo( "<?div class=\"entry\">\n" );
                echo( "<?h3>" );
                echo( "<?a href=\"" );
                the_permalink();
                echo( "\">" );
                the_title();
                echo( "<?/a>" );
                echo( "<?/h3>\n" );
                echo( "<?div class=\"time\">\n" );
                the_date();
                echo( "@" );
                the_time();
                echo( "<?/div>\n" );
                echo( "<?h4>in Categories<?/h4>" );
                the_category();
                the_content();
                echo( "<?/div>\n\n" );
            }
        }
    ?>

    Show Date Menu

    <?php
        echo("<h2>Archive</h2>\n");
        echo("<ul>\n");
        wp_get_archives();
        echo("</ul>\n");
    ?>

    Show Tag List

    <?php
        echo("<div id=\"tag-bar\">\n");
        echo("<ul>\n");
        $tags_obj = get_tags(array('orderby'=>'name','order'=>'ASC','hide_empty'=>'1'));
        foreach($tags_obj as $tag){
            echo("<li>");
            echo("<a href=\"/tag/".$tag->slug."\">".$tag->name."</a>");
            echo(" (".$tag->count.")");
            echo("</li>\n");
        }
        echo("</ul>\n");
        echo("</div>\n\n");
    ?>

    Add ability to execute php in text widgets

    <?php
    add_filter('widget_text','php_text',99);
    function php_text($text){
        if(strpos($text,'<'.'?')!==false){
            ob_start();
            eval('?'.'>'.$text);
            $text=ob_get_contents();
            ob_end_clean();
        }
        return $text;
    }
    ?>

    Removes the automatic addition of P and BR elements to content

    <?php
    remove_filter('the_content','wpautop');
    remove_filter('the_excerpt','wpautop');
    remove_filter('term_description','wpautop');
    ?>

    Using email as username in account registration

    <?php
    if(isset($_POST['user_login'])&&isset($_POST['user_email'])){
        $_POST['user_login']=$_POST['user_email'];
    }
    ?>

    Storing user-selected password into database on registration

    <?php
    add_action('user_register','ts_register_extra_fields',100);
    function ts_register_extra_fields($user_id){
        $userdata=array();
        $userdata['ID']=$user_id;
        if($_POST['user_password']!==''){
            $userdata['user_pass']=$_POST['user_password'];
        }
        $new_user_id=wp_update_user($userdata);
    }
    ?>

    Add ability to add featured images to pages and posts

    <?php
    add_theme_support('post-thumbnails');
    ?>

    Add ability to execute shortcodes in text widgets

    <?php
    add_filter('widget_text','do_shortcode');
    ?>

    Define menus

    <?php
    if(function_exists('register_nav_menus')){
        register_nav_menus(
            array(
                'main_menu'=>'Main Menu',
                'footer_menu'=>'Footer Menu',
            )
        );
    }
    ?>

    Define widget regions

    <?php
    if(function_exists('register_sidebar')){
        register_sidebar(array(
            'name'=>'Footer',
            'id'=>'footer',
            'before_widget'=>'<div>',
            'after_widget'=>'</div>',
            'before_title'=>'<h2>',
            'after_title'=>'</h2>',
        ));
        register_sidebar(array(
            'name'=>'Footer Right',
            'id'=>'footer_right',
            'before_widget'=>'<div>',
            'after_widget'=>'</div>',
            'before_title'=>'<h2>',
            'after_title'=>'</h2>',
        ));
        register_sidebar(array(
            'name'=>'Sidebar Right',
            'id'=>'sidebar_right',
            'before_widget'=>'<div>',
            'after_widget'=>'</div>',
            'before_title'=>'<h2>',
            'after_title'=>'</h2>',
        ));
    }
    ?>
  • Output a menu

    Context: 
    Connection: 
    Attribute Type: 
    Types
    Connection: 
    Weight: 
    100
    Attribute Type: 
    Topics
    Connection: 
    Weight: 
    100
    Attribute Type: 
    Topics
    <?php
    
    
    $page_menu_items = menu_tree_output(menu_tree_all_data("main-menu"));
    
    echo( drupal_render($page_menu_items) );
    
    
    ?>
  • LDAP Connect and Bind Test

    Context: 
    Connection: 
    Attribute Type: 
    Types
    Connection: 
    Weight: 
    100
    Attribute Type: 
    Topics
    Connection: 
    Weight: 
    100
    Attribute Type: 
    Topics
    <?php
    
    
    $host = "127.0.0.1:10389";
    $ldap = ldap_connect($host);
    ldap_set_option($ldap, LDAP_OPT_PROTOCOL_VERSION, 3);
    
    
    $username = "uid=admin,ou=system";
    $password = "secret";
    
    
    if( $bind = ldap_bind($ldap, $username, $password) )
    
        echo( "logged into ".$host." as ".$username );
    
    else
    
        echo( "Fail" );
    
    
    ?>
  • Create custom content type

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

    contenttypetest.info

    name = Contenttype test
    description = Test - how can I create a new content type with hook form?
    core = 7.x
    files[] = contenttypetest.module;
    files[] = contenttypetest.install;

    contenttypetest.module

    <?php
    
        // hook_form implementation
        function contenttypetest_form($node, &$form_state) {
            $form = array();
    
    
            $form['contenttypetest_pass'] = array(
                '#type' => 'password',
                '#title' => t('Type a password'),
                '#description' => t('You can type anything you like.'),
            );
            $form['contenttypetest_veld'] = array(
                '#type' => 'file',
                '#description' => 'You might wanna upload a file!',
                '#title' => 'Bestand',
            );
            return $form;
        }
    
    
        // hook_node_info() implementation
        function contenttypetest_node_info() {
            return array(
                'contenttypetest' => array(
                    'name' => t('Content type test node'),
                    'base' => 'contenttypetest',
                    'module' => 'contenttypetest',
                    'description' => t("This nodetype is a test how to create nodetypes."),
                    'help' => 'So this is how your new contenttype looks!',
                    'title_label' => t('Test'),
                    'has_body' => FALSE,
                ),
            );
        }
    
    
        // hook_validate() implementation
        function contenttypetest_validate(){
        }
    
    ?>

    contenttypetest.install

    <?php
    
        // hook_uninstall() implementation
        function contenttypetest_uninstall(){
            node_type_delete('contenttypetest');
        }
    
    ?>
  • Fill array with server request URI strings

    Context: 
    Connection: 
    Attribute Type: 
    Types
    Connection: 
    Weight: 
    100
    Attribute Type: 
    Topics
    Connection: 
    Weight: 
    100
    Attribute Type: 
    Topics
    <?php
    
    $request = explode( "/", $_SERVER["REQUEST_URI"] );
    array_shift( $request );
    
    print_r( $requests );
    
    ?>
  • Render imagecache images

    Context: 
    Connection: 
    Attribute Type: 
    Types
    Connection: 
    Weight: 
    100
    Attribute Type: 
    Topics
    Connection: 
    Weight: 
    100
    Attribute Type: 
    Topics
    echo( "<img src=\"".image_style_url("thumbnail", $photo["uri"] )."\" alt=\"\"/>" );
  • Add unique IDs to menu items

    Context: 
    Connection: 
    Attribute Type: 
    Types
    Connection: 
    Weight: 
    100
    Attribute Type: 
    Topics
    Connection: 
    Weight: 
    100
    Attribute Type: 
    Topics
    <?php
    function HOOK_menu_link( array $variables ){
    
        $element = $variables['element'];
        $sub_menu = '';
        $name_id = strtolower(strip_tags($element['#title']));
    
        // remove colons and anything past colons
        if (strpos($name_id, ':')) $name_id = substr ($name_id, 0, strpos($name_id, ':'));
    
        //Preserve alphanumerics, everything else goes away
        $pattern = '/[^a-z]+/ ';
        $name_id = preg_replace($pattern, '', $name_id);
    
        $element['#attributes']['id'][] = 'menu-' . $element['#original_link']['mlid'] . ' '.$name_id;
    
        if( $element['#below'] )
            $sub_menu = drupal_render($element['#below']);
    
        $output = l($element['#title'], $element['#href'], $element['#localized_options']);
    
        return '' . $output . $sub_menu . "
  • \n"; } ?>
  • Obtain matching entities

    Context: 
    Connection: 
    Attribute Type: 
    Types
    Connection: 
    Weight: 
    100
    Attribute Type: 
    Topics
    Connection: 
    Weight: 
    100
    Attribute Type: 
    Topics
    function obtain_entities_by_type($entity_type,$bundle,$limit=10,$offset=0,$subject_nid=FALSE){
    
        $query=new EntityFieldQuery();
    
        $query->entityCondition('entity_type', $entity_type)
            ->entityCondition('bundle', $bundle)
            ->propertyCondition('status', 1)
            ->range($offset, $limit);
    
        if($subject_nid)
            $query->fieldCondition('field_subject','nid',$subject_nid);
    
        $results=$query->execute();
    
        if(array_key_exists('node',$results))
            return entity_load($entity_type,array_keys($results[$entity_type]));
    
    }

    Useage

    obtain_entities_by_type('node','page',10,0,432);

    Or

    <?php
    $sql="SELECT node.nid AS nid,
    node.title AS node_title,
    node.created AS node_created,
    node_data_field_weight.field_weight_value AS node_data_field_weight_field_weight_value
     FROM node node
     LEFT JOIN content_field_weight node_data_field_weight ON node.vid = node_data_field_weight.vid
     WHERE (node.status <> 0)
        ORDER BY node_data_field_weight_field_weight_value DESC";
    
    $db_query=db_query($sql);
    
    $items=array();
    while($row=db_fetch_array($db_query))
    	$items[]=array( $row["node_title"], $row["node_created"], $row["nid"], $row["node_data_field_weight_field_weight_value"] );
    
    echo("<pre>".print_r($items,TRUE)."</pre>\n\n");
    
    ?>

    Or

    <?php
    function snag_drupal_pages(){
        $sql_children="SELECT node.nid AS nid, node.vid AS node_vid, node.title AS node_title
         FROM node node
         WHERE node.type in ('page')";
        $db_query_children = db_query($sql_children);
        $pages=array();
        foreach($db_query_children as $row){
        	$nd=node_load($row->nid);
        	$key=array_push( $pages,array() ) - 1;
        	$pages[$key]["id"] = $row->nid;
        	$pages[$key]["title"] = $nd->title;
        	$pages[$key]["date"] = $nd->created;
        	if( drupal_lookup_path('alias',"node/".$nd->nid) ) $pages[$key]["path"] = drupal_lookup_path('alias',"node/".$nd->nid);
        	else $pages[$key]["path"] = "node/".$nd->nid;
        	if( !empty($nd->field_parent_page) ) $pages[$key]["group"] = $nd->field_parent_page["und"][0]["nid"];
        }
        #echo("<pre>");print_r($pages);echo("</pre>\n");
        return $pages;
    }
    ?>
  • Show field when a different selection is made on the same form

    Context: 
    Connection: 
    Attribute Type: 
    Types
    Connection: 
    Weight: 
    100
    Attribute Type: 
    Topics
    Connection: 
    Weight: 
    100
    Attribute Type: 
    Topics
    Connection: 
    Weight: 
    100
    Attribute Type: 
    Topics
    function HOOK_form_alter( &$form, &$form_state, $form_id ){
    
        if( $form_id == "user_register_form" || $form_id == "user_profile_form" ) {
    
    
            // Shows OTHER text field when 'Other' is selected as their specialty
    
            $form["field_specialty_other"]["#states"] = array(
                "visible" => array(
                    ':input[name="field_specialty[und]"]' => array("value"=>"Other"),
                )
            );
    
    
        }
    
    }
  • Insert email as username at registration

    Context: 
    Connection: 
    Attribute Type: 
    Types
    Connection: 
    Weight: 
    100
    Attribute Type: 
    Topics
    Connection: 
    Weight: 
    100
    Attribute Type: 
    Topics
    <?php
    function HOOK_user_insert( &$edit, &$account, $category = NULL ){
    
        // Don't create a new username if one is already set
        if( strpos($account->name, 'temporary_') !== 0)
            return;
    
        // Otherwise, replace username with email address field
        db_update("users")
            ->fields(array("name" => $edit["mail"]))
            ->condition("uid", $account->uid)
            ->execute();
    
        $edit["name"] = $edit["mail"];
        $account->name = $edit["mail"];
        return;
    }
    
    
    function HOOK_user_register_form_alter( &$form, &$form_state, $form_id ){
    
        $form["account"]["name"]["#value"] = "temporary_".user_password();
        $form["account"]["name"]["#access"] = FALSE;
    
    }?>
  • Table

    items_table.tpl.php

    ID Images/Body Types Title Subjects Attributes Edit
    140 Macintosh
    EDIT
    139 lsof | grep /Volumes/IMAJIN diskutil unmountDisk force /Volumes/IMAJIN see what is accessing disk / force unmount disk
    EDIT
    138 Hosting
    EDIT
    135 <?php $reflFunc=new ReflectionFunction('name_of_function'); echo($reflFunc->getFileName().':'.$reflFunc->getStartLine()); ?> Find which file a function is defined in
    EDIT
    134 Adds custom post type called "Reviews" <?php function create_post_type(){ register_post_type('review', array( 'labels'=>array( 'name'=>__('Reviews'), 'singular_name'=>__('Review') ), 'public'=>true, 'has_archive'=>true, 'capabilities'=>array( 'edit_post'=>'edit_review', 'edit_posts'=>'edit_reviews', 'publish_posts'=>'publish_review', 'read_post'=>'read_review', ), ) ); } add_action('init','creat Custom Post Types
    EDIT
    71 In the Weeds
    EDIT
    132 <?php // Adds custom post type for Projects and Services function create_post_type(){ register_post_type('project', array( 'labels' => array( 'name' => __('Projects'), 'singular_name' => __('Project') ), 'taxonomies' => array('category'), 'public' => true, 'has_archive' => true, 'capabilities' => array( 'edit_post' => 'edit_project', 'edit_posts' => 'edit_projects', 'publish_posts' => 'publish_project', Post referencing setup
    EDIT
    36 Covidien Portal
    EDIT
    131 Foster Care Training
    EDIT
    130 AG & Associates
    EDIT
    129 Calvin Associates
    EDIT
    128 Ferber Law
    EDIT
    127 Oakland Police
    EDIT
    78 Orgnsm (ROOT)
    EDIT
    137 Tru frame
    EDIT
    136 Lotto-rithm
    EDIT
    133 Rate Your Customer / Rate My Contractor
    EDIT
    125 IXIAS
    EDIT
    19 NeuroGenesix
    EDIT
    126 TTF - Works in most browsers except IE and iPhone EOT - IE only WOFF - Compressed, emerging standard SVG - iPhone/iPad Font-embed Rundown
    EDIT
    124 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('.fle Using jQuery flexslider with animated captions callback
    EDIT
    1 Topics
    EDIT
    122 MySQL
    EDIT
    121 DELETE FROM `field_config` WHERE `field_config`.`deleted` = 1;
    Removes fields pending for deletion to uninstall a stuck module
    EDIT
    120 <?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); } ?> Reading/setting Drupal config variables
    EDIT
    119 <?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_ Migrates multigroups in D6 to field collections in D7
    EDIT
    116 Google
    EDIT
    115 Organic Connectivity Module
    • :112
    EDIT
    114 <?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(); Drupal DB Query to find Children (Recursively)
    EDIT
    113 <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> Similar by Taxonomy
    EDIT
    112 Wordpress
    EDIT
    111 <?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_' . $f Rename stuck field names
    EDIT
    110 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> OSX Virtual Web Host Config
    EDIT
    109 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; MySQL Basics
    EDIT
    108 <?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 nec Manually reset Drupal admin password
    EDIT
    106 PHP
    EDIT
    105 JQuery
    EDIT
    104 <?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') Nested-query approach to mining field_collection data and relationship
    EDIT
    103 <?php symlink('/homepages/21/d93015512/htdocs/library/organic_connectivity', '/homepages/21/d93015512/htdocs/drupal/sites/all/modules/organic_connectivity/lib'); ?> Create symlinks
    EDIT
    102 Trauma Informed Care
    EDIT
    101 Show Links Menu w/Active Class <nav> <?php $args=array( 'sort_order' => 'ASC', 'sort_column' => 'post_date', 'hierarchical' => 1, 'exclude' => '', 'include' => '', 'meta_key' => '', 'meta_value' => '', 'authors' => '', 'child_of' => 0, 'parent' => -1, 'exclude_tree' => '', 'number' => '', 'offset' => 0, 'post_type' => 'page', 'post_status' => 'publish' ); $pages = get_pages($args); $current_id = get_the_ID(); if( $pages ){ echo( "<ul>\n" ); fore Various WP snippets
    EDIT
    100 <?php $page_menu_items = menu_tree_output(menu_tree_all_data("main-menu")); echo( drupal_render($page_menu_items) ); ?> Output a menu
    EDIT
    99 <?php $host = "127.0.0.1:10389"; $ldap = ldap_connect($host); ldap_set_option($ldap, LDAP_OPT_PROTOCOL_VERSION, 3); $username = "uid=admin,ou=system"; $password = "secret"; if( $bind = ldap_bind($ldap, $username, $password) ) echo( "logged into ".$host." as ".$username ); else echo( "Fail" ); ?> LDAP Connect and Bind Test
    EDIT
    98 contenttypetest.info name = Contenttype test description = Test - how can I create a new content type with hook form? core = 7.x files[] = contenttypetest.module; files[] = contenttypetest.install; contenttypetest.module <?php // hook_form implementation function contenttypetest_form($node, &$form_state) { $form = array(); $form['contenttypetest_pass'] = array( '#type' => 'password', '#title' => t('Type a password'), '#description' => t('You can type Create custom content type
    EDIT
    97 <?php $request = explode( "/", $_SERVER["REQUEST_URI"] ); array_shift( $request ); print_r( $requests ); ?> Fill array with server request URI strings
    EDIT
    96 echo( "<img src=\"".image_style_url("thumbnail", $photo["uri"] )."\" alt=\"\"/>" ); Render imagecache images
    EDIT
    95 <?php function HOOK_menu_link( array $variables ){ $element = $variables['element']; $sub_menu = ''; $name_id = strtolower(strip_tags($element['#title'])); // remove colons and anything past colons if (strpos($name_id, ':')) $name_id = substr ($name_id, 0, strpos($name_id, ':')); //Preserve alphanumerics, everything else goes away $pattern = '/[^a-z]+/ '; $name_id = preg_replace($pattern, '', $name_id); $element['#attributes']['id'][] = 'menu-' . $element['#original_link']['mlid'] . ' '.$name_ Add unique IDs to menu items
    EDIT
    94 function obtain_entities_by_type($entity_type,$bundle,$limit=10,$offset=0,$subject_nid=FALSE){ $query=new EntityFieldQuery(); $query->entityCondition('entity_type', $entity_type) ->entityCondition('bundle', $bundle) ->propertyCondition('status', 1) ->range($offset, $limit); if($subject_nid) $query->fieldCondition('field_subject','nid',$subject_nid); $results=$query->execute(); if(array_key_exists('node',$results)) return entity_load($entity_type,array_k Obtain matching entities
    EDIT
    93 function HOOK_form_alter( &$form, &$form_state, $form_id ){ if( $form_id == "user_register_form" || $form_id == "user_profile_form" ) { // Shows OTHER text field when 'Other' is selected as their specialty $form["field_specialty_other"]["#states"] = array( "visible" => array( ':input[name="field_specialty[und]"]' => array("value"=>"Other"), ) ); } } Show field when a different selection is made on the same form
    EDIT
    92 <?php function HOOK_user_insert( &$edit, &$account, $category = NULL ){ // Don't create a new username if one is already set if( strpos($account->name, 'temporary_') !== 0) return; // Otherwise, replace username with email address field db_update("users") ->fields(array("name" => $edit["mail"])) ->condition("uid", $account->uid) ->execute(); $edit["name"] = $edit["mail"]; $account->name = $edit["mail"]; return; } function HOOK_user_register_form_alter( &am Insert email as username at registration
    EDIT

    Rotator

    items_cinema.tpl.php

    Calendar

    date_overview.tpl.php

    Start date

    Total Items

    RSS

    items_syndicate.tpl.php

    
    
    
        
    
            Organic Interfaces
    
            http://interfaces.orgnsm.org/syndicate
    
            Recent Web Design & Info Code
    
            en
    
            Sun, 24 Dec 2023 14:08:52 -1000
    
            
    
    
     Macintosh
     http://interfaces.orgnsm.org/node/140
     
     140
     Sun, 24 Dec 2023 14:08:52 -1000
     
    
    
    
     see what is accessing disk / force unmount disk
     http://interfaces.orgnsm.org/node/139
     lsof | grep /Volumes/IMAJIN
    
    
    
    
    diskutil unmountDisk force /Volumes/IMAJIN
    ]]> 139 Sun, 24 Dec 2023 14:08:19 -1000 Hosting http://interfaces.orgnsm.org/node/138 ]]> 138 Mon, 17 Jul 2017 11:54:30 -1000 http://interfaces.orgnsm.org/sites/interfaces.orgnsm.org/files/styles/large-landscape-or-portrait/public/webhosting.png?itok=P_Wuceo8 Find which file a function is defined in http://interfaces.orgnsm.org/node/135 <?php $reflFunc=new ReflectionFunction('name_of_function'); echo($reflFunc->getFileName().':'.$reflFunc->getStartLine()); ?> ]]> 135 Mon, 26 Dec 2016 10:42:09 -1000 Custom Post Types http://interfaces.orgnsm.org/node/134 Adds custom post type called "Reviews"
    <?php
    function create_post_type(){
      register_post_type('review',
        array(
          'labels'=>array(
            'name'=>__('Reviews'),
            'singular_name'=>__('Review')
          ),
          'public'=>true,
          'has_archive'=>true,
          'capabilities'=>array(
              'edit_post'=>'edit_review',
              'edit_posts'=>'edit_reviews',
              'publish_posts'=>'publish_review',
              'read_post'=>'read_review',
          ),
        )
      );
    }
    add_action('init','create_post_type');
    ?>

    Add abilities to "Reviews" post type

    <?php
    function add_theme_caps(){
        $subscribers=get_role('subscriber');
        $subscribers->add_cap('edit_review');
        $subscribers->add_cap('edit_reviews');
        $subscribers->add_cap('publish_review');
        $subscribers->add_cap('read_review');
        $admins=get_role('administrator');
        $admins->add_cap('edit_review');
        $admins->add_cap('edit_reviews');
        $admins->add_cap('publish_review');
        $admins->add_cap('read_review');
    }
    add_action('admin_init','add_theme_caps');
    ?>

    Add custom fields to "Reviews" post type

    <?php
    add_action('admin_init','add_review_metas');
    function add_review_metas(){
      add_meta_box('review_rating-meta','Rating','review_rating','review','normal','low');
    }
    function review_rating(){
      global $post;
      $custom=get_post_custom($post->ID);
      $review_rating=$custom['review_rating'][0];
        for($x=1;$x<6;$x++){
            echo('<input');
            if($x==$review_rating) echo(' checked="checked"');
            echo(' type="radio" name="review_rating" id="review_rating_'.$x.'" value="'.$x.'"/><label for="review_rating_'.$x.'">'.$x.'</label>'."\n");
    
        }
    }
    add_action('save_post','save_details');
    function save_details(){
      global $post;
      update_post_meta($post->ID,'review_rating',$_POST["review_rating"]);
    }
    ?>
    ]]>
    134 Sun, 25 Dec 2016 13:03:50 -1000
    In the Weeds http://interfaces.orgnsm.org/node/71 ]]> 71 Tue, 06 Dec 2016 17:03:10 -1000 http://interfaces.orgnsm.org/sites/interfaces.orgnsm.org/files/styles/large-landscape-or-portrait/public/itw_homepage_2_0.png?itok=zrQuef0l Post referencing setup http://interfaces.orgnsm.org/node/132 <?php // Adds custom post type for Projects and Services function create_post_type(){ register_post_type('project', array( 'labels' => array( 'name' => __('Projects'), 'singular_name' => __('Project') ), 'taxonomies' => array('category'), 'public' => true, 'has_archive' => true, 'capabilities' => array( 'edit_post' => 'edit_project', 'edit_posts' => 'edit_projects', 'publish_posts' => 'publish_project', 'read_post' => 'read_project', ), 'supports' => array( 'title','editor','thumbnail' ), ) ); register_post_type('service', array( 'labels' => array( 'name' => __('Services'), 'singular_name' => __('Service') ), 'public' => true, 'has_archive' => true, 'capabilities' => array( 'edit_post' => 'edit_service', 'edit_posts' => 'edit_services', 'publish_posts' => 'publish_service', 'read_post' => 'read_service', ), 'supports' => array( 'title','editor','thumbnail' ), ) ); } add_action('init','create_post_type'); function add_theme_caps(){ $subscribers = get_role( 'subscriber' ); //$subscribers->add_cap( 'edit_project' ); //$subscribers->add_cap( 'edit_projects' ); //$subscribers->add_cap( 'publish_project' ); $subscribers->add_cap( 'read_project' ); $subscribers->add_cap( 'read_service' ); $admins = get_role( 'administrator' ); $admins->add_cap( 'edit_project' ); $admins->add_cap( 'edit_projects' ); $admins->add_cap( 'publish_project' ); $admins->add_cap( 'read_project' ); $admins->add_cap( 'edit_service' ); $admins->add_cap( 'edit_services' ); $admins->add_cap( 'publish_service' ); $admins->add_cap( 'read_service' ); } add_action('init','add_theme_caps'); // Adds custom field to the PROJECT custom post type function add_project_metas(){ add_meta_box( 'project_service-meta', 'Service', 'project_service', 'project', 'normal', 'low' ); } add_action('admin_init','add_project_metas'); function project_service(){ global $post; $custom=get_post_custom($post->ID); $project_services=$custom['project_service'][0]; $project_services=unserialize($project_services); $args=array( 'post_type'=>'service', 'posts_per_page'=>'200', 'orderby'=>'title', 'order'=>'ASC' ); $loop=new WP_Query($args); while($loop->have_posts()):$loop->the_post(); echo('<div><input type="checkbox" name="project_services[]" value="'.get_the_ID().'" id="project_service_'.get_the_ID().'"'); if(is_array($project_services)&&in_array(get_the_ID(),$project_services)) echo(' checked="checked"'); //checked($project_services,get_the_ID()); echo('><label for="project_service_'.get_the_ID().'">'.get_the_title(get_the_ID()).'</label></div>'); endwhile; } function save_details(){ global $post; update_post_meta($post->ID,'project_service',$_POST["project_services"]); } add_action('save_post','save_details'); ?> ]]> 132 Thu, 01 Dec 2016 16:46:51 -1000 Covidien Portal http://interfaces.orgnsm.org/node/36 ]]> 36 Thu, 03 Nov 2016 14:38:17 -1000 http://interfaces.orgnsm.org/sites/interfaces.orgnsm.org/files/styles/large-landscape-or-portrait/public/2014-02-03_1.png?itok=R5zFP4zs Foster Care Training http://interfaces.orgnsm.org/node/131 ]]> 131 Tue, 25 Oct 2016 10:58:38 -1000 http://interfaces.orgnsm.org/sites/interfaces.orgnsm.org/files/styles/large-landscape-or-portrait/public/fostercaretraining_1.png?itok=RsX5KtlF AG & Associates http://interfaces.orgnsm.org/node/130 ]]> 130 Tue, 25 Oct 2016 10:57:52 -1000 http://interfaces.orgnsm.org/sites/interfaces.orgnsm.org/files/styles/large-landscape-or-portrait/public/agassociates_1.png?itok=8e78XVFA Calvin Associates http://interfaces.orgnsm.org/node/129 ]]> 129 Tue, 25 Oct 2016 10:57:28 -1000 http://interfaces.orgnsm.org/sites/interfaces.orgnsm.org/files/styles/large-landscape-or-portrait/public/calvin_2.png?itok=zy0cDiNQ Ferber Law http://interfaces.orgnsm.org/node/128 ]]> 128 Tue, 25 Oct 2016 10:41:45 -1000 http://interfaces.orgnsm.org/sites/interfaces.orgnsm.org/files/styles/large-landscape-or-portrait/public/ferberlaw_1.png?itok=_Y6l_Vqr Oakland Police http://interfaces.orgnsm.org/node/127 ]]> 127 Tue, 25 Oct 2016 10:41:24 -1000 http://interfaces.orgnsm.org/sites/interfaces.orgnsm.org/files/styles/large-landscape-or-portrait/public/oakland_police_1.png?itok=NpLNZGYx Orgnsm (ROOT) http://interfaces.orgnsm.org/node/78 ]]> 78 Mon, 15 Aug 2016 22:54:27 -1000 http://interfaces.orgnsm.org/sites/interfaces.orgnsm.org/files/styles/large-landscape-or-portrait/public/2015-09-25.png?itok=OEBSXJSX Tru frame http://interfaces.orgnsm.org/node/137 ]]> 137 Sat, 16 Jan 2016 12:16:43 -1000 http://interfaces.orgnsm.org/sites/interfaces.orgnsm.org/files/styles/large-landscape-or-portrait/public/WEB%20CLIENTS_truframe.jpg?itok=o41yTW1n Lotto-rithm http://interfaces.orgnsm.org/node/136 ]]> 136 Sat, 16 Jan 2016 12:16:21 -1000 http://interfaces.orgnsm.org/sites/interfaces.orgnsm.org/files/styles/large-landscape-or-portrait/public/WEB%20CLIENTS_lotto-rithm.jpg?itok=mWsgoSFc Rate Your Customer / Rate My Contractor http://interfaces.orgnsm.org/node/133 ]]> 133 Fri, 25 Dec 2015 12:46:46 -1000 http://interfaces.orgnsm.org/sites/interfaces.orgnsm.org/files/styles/large-landscape-or-portrait/public/rate-your-customer-1.png?itok=iCcMhL2y IXIAS http://interfaces.orgnsm.org/node/125 ]]> 125 Thu, 20 Aug 2015 15:21:39 -1000 http://interfaces.orgnsm.org/sites/interfaces.orgnsm.org/files/styles/large-landscape-or-portrait/public/2016-03-23.png?itok=MaMyLOHQ NeuroGenesix http://interfaces.orgnsm.org/node/19 ]]> 19 Wed, 29 Jul 2015 01:55:27 -1000 http://interfaces.orgnsm.org/sites/interfaces.orgnsm.org/files/styles/large-landscape-or-portrait/public/neuro_2009-11-22_1.png?itok=ZAApFV0d Font-embed Rundown http://interfaces.orgnsm.org/node/126 TTF - Works in most browsers except IE and iPhone EOT - IE only WOFF - Compressed, emerging standard SVG - iPhone/iPad ]]> 126 Sun, 28 Sep 2014 10:08:27 -1000 Using jQuery flexslider with animated captions callback http://interfaces.orgnsm.org/node/124 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;
    }
    ]]>
    124 Thu, 04 Sep 2014 17:45:54 -1000
    Topics http://interfaces.orgnsm.org/node/1 ]]> 1 Thu, 17 Jul 2014 01:42:57 -1000 http://interfaces.orgnsm.org/sites/interfaces.orgnsm.org/files/styles/large-landscape-or-portrait/public/Mind_Map_Template_Mulit_Rounded.jpg?itok=A9z-BipE MySQL http://interfaces.orgnsm.org/node/122 122 Sun, 13 Jul 2014 19:38:09 -1000 Removes fields pending for deletion to uninstall a stuck module http://interfaces.orgnsm.org/node/121 DELETE FROM `field_config` WHERE `field_config`.`deleted` = 1; ]]> 121 Sun, 13 Jul 2014 19:37:35 -1000 Reading/setting Drupal config variables http://interfaces.orgnsm.org/node/120 <?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); } ?> ]]> 120 Sun, 13 Jul 2014 19:23:23 -1000 Migrates multigroups in D6 to field collections in D7 http://interfaces.orgnsm.org/node/119 <?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"; } ?> ]]> 119 Wed, 09 Jul 2014 00:20:20 -1000 Google http://interfaces.orgnsm.org/node/116 116 Mon, 12 May 2014 20:57:24 -1000 Organic Connectivity Module http://interfaces.orgnsm.org/node/115 ]]> 115 Mon, 12 May 2014 20:44:44 -1000 http://interfaces.orgnsm.org/sites/interfaces.orgnsm.org/files/styles/large-landscape-or-portrait/public/organic_gallery_viewer_icons.png?itok=iOeTFnuv Drupal DB Query to find Children (Recursively) http://interfaces.orgnsm.org/node/114 <?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']));
    
    ]]>
    114 Fri, 09 May 2014 01:21:13 -1000
    Similar by Taxonomy http://interfaces.orgnsm.org/node/113 <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"); } } } ?> ]]> 113 Mon, 28 Apr 2014 21:00:56 -1000 Wordpress http://interfaces.orgnsm.org/node/112 ]]> 112 Mon, 28 Apr 2014 19:08:21 -1000 http://interfaces.orgnsm.org/sites/interfaces.orgnsm.org/files/styles/large-landscape-or-portrait/public/wordpress-logo-notext-rgb.png?itok=kbCsVk7S Rename stuck field names http://interfaces.orgnsm.org/node/111 <?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. ?> ]]> 111 Fri, 21 Feb 2014 15:11:51 -1000 OSX Virtual Web Host Config http://interfaces.orgnsm.org/node/110 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>
    ]]>
    110 Thu, 20 Feb 2014 15:47:56 -1000
    MySQL Basics http://interfaces.orgnsm.org/node/109 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;
    ]]>
    109 Wed, 12 Feb 2014 15:56:49 -1000
    Manually reset Drupal admin password http://interfaces.orgnsm.org/node/108 <?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(); ?> ]]> 108 Wed, 12 Feb 2014 13:22:45 -1000 PHP http://interfaces.orgnsm.org/node/106 ]]> 106 Wed, 05 Feb 2014 16:09:09 -1000 http://interfaces.orgnsm.org/sites/interfaces.orgnsm.org/files/styles/large-landscape-or-portrait/public/icon_php.png?itok=147fsMIa JQuery http://interfaces.orgnsm.org/node/105 ]]> 105 Wed, 05 Feb 2014 15:20:21 -1000 http://interfaces.orgnsm.org/sites/interfaces.orgnsm.org/files/styles/large-landscape-or-portrait/public/icon_jquery.gif?itok=0IVQvzvR Nested-query approach to mining field_collection data and relationship http://interfaces.orgnsm.org/node/104 <?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; } ?> ]]> 104 Wed, 05 Feb 2014 15:15:00 -1000 Create symlinks http://interfaces.orgnsm.org/node/103 <?php symlink('/homepages/21/d93015512/htdocs/library/organic_connectivity', '/homepages/21/d93015512/htdocs/drupal/sites/all/modules/organic_connectivity/lib'); ?> ]]> 103 Mon, 20 Jan 2014 14:39:51 -1000 Trauma Informed Care http://interfaces.orgnsm.org/node/102 ]]> 102 Wed, 18 Dec 2013 17:48:59 -1000 http://interfaces.orgnsm.org/sites/interfaces.orgnsm.org/files/styles/large-landscape-or-portrait/public/2013-12-22_1.png?itok=So61PE2q Various WP snippets http://interfaces.orgnsm.org/node/101 Show Links Menu w/Active Class
    <nav>
    <?php $args=array(
    	'sort_order' => 'ASC',
    	'sort_column' => 'post_date',
    	'hierarchical' => 1,
    	'exclude' => '',
    	'include' => '',
    	'meta_key' => '',
    	'meta_value' => '',
    	'authors' => '',
    	'child_of' => 0,
    	'parent' => -1,
    	'exclude_tree' => '',
    	'number' => '',
    	'offset' => 0,
    	'post_type' => 'page',
    	'post_status' => 'publish'
    );
    $pages = get_pages($args);
    $current_id = get_the_ID();
    if( $pages ){
        echo( "<ul>\n" );
        foreach( $pages as $page){
            $link_page_id = ($page->ID);
            if( $current_id==$link_page_id ) echo( "<li class=\"active\">" );
            else echo( "<li>" );
            echo( "<a href=\"".get_page_link($page->ID)."\">".$page->post_title."</a>" );
            echo( "</li>\n" );
        }
        echo( "</ul>\n\n" );
    }
    ?>
    </nav>

    Show Categories List

    <?php
        echo( "<div id=\"topics\">\n" );
        echo( "<h3>Topics</h3>\n" );
        echo( "<ul>\n" );
        $categories_obj = get_categories( array('orderby'=>'id','hide_empty'=>'1') );
        foreach( $categories_obj as $cat ){
            echo( "<li>" );
            echo( "<a href=\"/category/".$cat->slug."\">".$cat->name."</a>" );
            $posts_in_cat = new WP_Query( 'cat='.$cat->term_id );
            if ( $posts_in_cat->have_posts() ){
                echo( "<ul>\n" );
                while ( $posts_in_cat->have_posts() ){
                    $posts_in_cat->the_post();
                    echo( "<li><a href=\"");
                    the_permalink();
                    echo( "\">" );
                    the_title();
                    echo( "</a></li>\n" );
                }
                echo( "</ul>\n" );
            }
            echo( "</li>\n" );
        }
        echo( "</ul>\n" );
        echo( "</div>\n\n" );
    ?>

    Show Recent Posts List

    <?php
        echo( "<h2>What's New</h2>\n" );
        echo( "<ul>\n" );
        $latest_blog_posts = new WP_Query( array('posts_per_page'=>5) );
        if ( $latest_blog_posts->have_posts() ) :
            while ( $latest_blog_posts->have_posts() ) :
                $latest_blog_posts->the_post();
                // Loop output goes here
                echo( "<li><a href=\"");
                the_permalink();
                echo( "\">" );
                the_title();
                echo( "</a></li>\n" );
            endwhile;
        endif;
        echo( "</ul>\n" );
    }
    ?>

    Show Recent Posts Content

    <?php
        echo( "<?h2>Recent Posts<?/h2>\n" );
        $latest_blog_posts = new WP_Query( array( 'posts_per_page'=>5 ) );
        if ( $latest_blog_posts->have_posts() ){
            while ( $latest_blog_posts->have_posts() ){
                $latest_blog_posts->the_post();
                // Loop output goes here
                echo( "<?div class=\"entry\">\n" );
                echo( "<?h3>" );
                echo( "<?a href=\"" );
                the_permalink();
                echo( "\">" );
                the_title();
                echo( "<?/a>" );
                echo( "<?/h3>\n" );
                echo( "<?div class=\"time\">\n" );
                the_date();
                echo( "@" );
                the_time();
                echo( "<?/div>\n" );
                echo( "<?h4>in Categories<?/h4>" );
                the_category();
                the_content();
                echo( "<?/div>\n\n" );
            }
        }
    ?>

    Show Date Menu

    <?php
        echo("<h2>Archive</h2>\n");
        echo("<ul>\n");
        wp_get_archives();
        echo("</ul>\n");
    ?>

    Show Tag List

    <?php
        echo("<div id=\"tag-bar\">\n");
        echo("<ul>\n");
        $tags_obj = get_tags(array('orderby'=>'name','order'=>'ASC','hide_empty'=>'1'));
        foreach($tags_obj as $tag){
            echo("<li>");
            echo("<a href=\"/tag/".$tag->slug."\">".$tag->name."</a>");
            echo(" (".$tag->count.")");
            echo("</li>\n");
        }
        echo("</ul>\n");
        echo("</div>\n\n");
    ?>

    Add ability to execute php in text widgets

    <?php
    add_filter('widget_text','php_text',99);
    function php_text($text){
        if(strpos($text,'<'.'?')!==false){
            ob_start();
            eval('?'.'>'.$text);
            $text=ob_get_contents();
            ob_end_clean();
        }
        return $text;
    }
    ?>

    Removes the automatic addition of P and BR elements to content

    <?php
    remove_filter('the_content','wpautop');
    remove_filter('the_excerpt','wpautop');
    remove_filter('term_description','wpautop');
    ?>

    Using email as username in account registration

    <?php
    if(isset($_POST['user_login'])&&isset($_POST['user_email'])){
        $_POST['user_login']=$_POST['user_email'];
    }
    ?>

    Storing user-selected password into database on registration

    <?php
    add_action('user_register','ts_register_extra_fields',100);
    function ts_register_extra_fields($user_id){
        $userdata=array();
        $userdata['ID']=$user_id;
        if($_POST['user_password']!==''){
            $userdata['user_pass']=$_POST['user_password'];
        }
        $new_user_id=wp_update_user($userdata);
    }
    ?>

    Add ability to add featured images to pages and posts

    <?php
    add_theme_support('post-thumbnails');
    ?>

    Add ability to execute shortcodes in text widgets

    <?php
    add_filter('widget_text','do_shortcode');
    ?>

    Define menus

    <?php
    if(function_exists('register_nav_menus')){
        register_nav_menus(
            array(
                'main_menu'=>'Main Menu',
                'footer_menu'=>'Footer Menu',
            )
        );
    }
    ?>

    Define widget regions

    <?php
    if(function_exists('register_sidebar')){
        register_sidebar(array(
            'name'=>'Footer',
            'id'=>'footer',
            'before_widget'=>'<div>',
            'after_widget'=>'</div>',
            'before_title'=>'<h2>',
            'after_title'=>'</h2>',
        ));
        register_sidebar(array(
            'name'=>'Footer Right',
            'id'=>'footer_right',
            'before_widget'=>'<div>',
            'after_widget'=>'</div>',
            'before_title'=>'<h2>',
            'after_title'=>'</h2>',
        ));
        register_sidebar(array(
            'name'=>'Sidebar Right',
            'id'=>'sidebar_right',
            'before_widget'=>'<div>',
            'after_widget'=>'</div>',
            'before_title'=>'<h2>',
            'after_title'=>'</h2>',
        ));
    }
    ?>
    ]]>
    101 Tue, 17 Dec 2013 20:02:27 -1000
    Output a menu http://interfaces.orgnsm.org/node/100 <?php $page_menu_items = menu_tree_output(menu_tree_all_data("main-menu")); echo( drupal_render($page_menu_items) ); ?> ]]> 100 Tue, 17 Dec 2013 17:33:26 -1000 LDAP Connect and Bind Test http://interfaces.orgnsm.org/node/99 <?php $host = "127.0.0.1:10389"; $ldap = ldap_connect($host); ldap_set_option($ldap, LDAP_OPT_PROTOCOL_VERSION, 3); $username = "uid=admin,ou=system"; $password = "secret"; if( $bind = ldap_bind($ldap, $username, $password) ) echo( "logged into ".$host." as ".$username ); else echo( "Fail" ); ?> ]]> 99 Fri, 13 Dec 2013 20:41:40 -1000 Create custom content type http://interfaces.orgnsm.org/node/98 contenttypetest.info
    name = Contenttype test
    description = Test - how can I create a new content type with hook form?
    core = 7.x
    files[] = contenttypetest.module;
    files[] = contenttypetest.install;

    contenttypetest.module

    <?php
    
        // hook_form implementation
        function contenttypetest_form($node, &$form_state) {
            $form = array();
    
    
            $form['contenttypetest_pass'] = array(
                '#type' => 'password',
                '#title' => t('Type a password'),
                '#description' => t('You can type anything you like.'),
            );
            $form['contenttypetest_veld'] = array(
                '#type' => 'file',
                '#description' => 'You might wanna upload a file!',
                '#title' => 'Bestand',
            );
            return $form;
        }
    
    
        // hook_node_info() implementation
        function contenttypetest_node_info() {
            return array(
                'contenttypetest' => array(
                    'name' => t('Content type test node'),
                    'base' => 'contenttypetest',
                    'module' => 'contenttypetest',
                    'description' => t("This nodetype is a test how to create nodetypes."),
                    'help' => 'So this is how your new contenttype looks!',
                    'title_label' => t('Test'),
                    'has_body' => FALSE,
                ),
            );
        }
    
    
        // hook_validate() implementation
        function contenttypetest_validate(){
        }
    
    ?>

    contenttypetest.install

    <?php
    
        // hook_uninstall() implementation
        function contenttypetest_uninstall(){
            node_type_delete('contenttypetest');
        }
    
    ?>
    ]]>
    98 Wed, 11 Dec 2013 12:42:24 -1000
    Fill array with server request URI strings http://interfaces.orgnsm.org/node/97 <?php $request = explode( "/", $_SERVER["REQUEST_URI"] ); array_shift( $request ); print_r( $requests ); ?> ]]> 97 Mon, 09 Dec 2013 17:20:59 -1000 Render imagecache images http://interfaces.orgnsm.org/node/96 echo( "<img src=\"".image_style_url("thumbnail", $photo["uri"] )."\" alt=\"\"/>" ); ]]> 96 Sun, 08 Dec 2013 19:21:51 -1000 Add unique IDs to menu items http://interfaces.orgnsm.org/node/95 <?php function HOOK_menu_link( array $variables ){ $element = $variables['element']; $sub_menu = ''; $name_id = strtolower(strip_tags($element['#title'])); // remove colons and anything past colons if (strpos($name_id, ':')) $name_id = substr ($name_id, 0, strpos($name_id, ':')); //Preserve alphanumerics, everything else goes away $pattern = '/[^a-z]+/ '; $name_id = preg_replace($pattern, '', $name_id); $element['#attributes']['id'][] = 'menu-' . $element['#original_link']['mlid'] . ' '.$name_id; if( $element['#below'] ) $sub_menu = drupal_render($element['#below']); $output = l($element['#title'], $element['#href'], $element['#localized_options']); return '' . $output . $sub_menu . "\n"; } ?> ]]> 95 Fri, 06 Dec 2013 14:58:18 -1000 Obtain matching entities http://interfaces.orgnsm.org/node/94 function obtain_entities_by_type($entity_type,$bundle,$limit=10,$offset=0,$subject_nid=FALSE){ $query=new EntityFieldQuery(); $query->entityCondition('entity_type', $entity_type) ->entityCondition('bundle', $bundle) ->propertyCondition('status', 1) ->range($offset, $limit); if($subject_nid) $query->fieldCondition('field_subject','nid',$subject_nid); $results=$query->execute(); if(array_key_exists('node',$results)) return entity_load($entity_type,array_keys($results[$entity_type])); }

    Useage

    obtain_entities_by_type('node','page',10,0,432);

    Or

    <?php
    $sql="SELECT node.nid AS nid,
    node.title AS node_title,
    node.created AS node_created,
    node_data_field_weight.field_weight_value AS node_data_field_weight_field_weight_value
     FROM node node
     LEFT JOIN content_field_weight node_data_field_weight ON node.vid = node_data_field_weight.vid
     WHERE (node.status <> 0)
        ORDER BY node_data_field_weight_field_weight_value DESC";
    
    $db_query=db_query($sql);
    
    $items=array();
    while($row=db_fetch_array($db_query))
    	$items[]=array( $row["node_title"], $row["node_created"], $row["nid"], $row["node_data_field_weight_field_weight_value"] );
    
    echo("<pre>".print_r($items,TRUE)."</pre>\n\n");
    
    ?>

    Or

    <?php
    function snag_drupal_pages(){
        $sql_children="SELECT node.nid AS nid, node.vid AS node_vid, node.title AS node_title
         FROM node node
         WHERE node.type in ('page')";
        $db_query_children = db_query($sql_children);
        $pages=array();
        foreach($db_query_children as $row){
        	$nd=node_load($row->nid);
        	$key=array_push( $pages,array() ) - 1;
        	$pages[$key]["id"] = $row->nid;
        	$pages[$key]["title"] = $nd->title;
        	$pages[$key]["date"] = $nd->created;
        	if( drupal_lookup_path('alias',"node/".$nd->nid) ) $pages[$key]["path"] = drupal_lookup_path('alias',"node/".$nd->nid);
        	else $pages[$key]["path"] = "node/".$nd->nid;
        	if( !empty($nd->field_parent_page) ) $pages[$key]["group"] = $nd->field_parent_page["und"][0]["nid"];
        }
        #echo("<pre>");print_r($pages);echo("</pre>\n");
        return $pages;
    }
    ?>
    ]]>
    94 Thu, 05 Dec 2013 18:13:58 -1000
    Show field when a different selection is made on the same form http://interfaces.orgnsm.org/node/93 function HOOK_form_alter( &$form, &$form_state, $form_id ){ if( $form_id == "user_register_form" || $form_id == "user_profile_form" ) { // Shows OTHER text field when 'Other' is selected as their specialty $form["field_specialty_other"]["#states"] = array( "visible" => array( ':input[name="field_specialty[und]"]' => array("value"=>"Other"), ) ); } } ]]> 93 Tue, 03 Dec 2013 16:09:46 -1000 Insert email as username at registration http://interfaces.orgnsm.org/node/92 <?php function HOOK_user_insert( &$edit, &$account, $category = NULL ){ // Don't create a new username if one is already set if( strpos($account->name, 'temporary_') !== 0) return; // Otherwise, replace username with email address field db_update("users") ->fields(array("name" => $edit["mail"])) ->condition("uid", $account->uid) ->execute(); $edit["name"] = $edit["mail"]; $account->name = $edit["mail"]; return; } function HOOK_user_register_form_alter( &$form, &$form_state, $form_id ){ $form["account"]["name"]["#value"] = "temporary_".user_password(); $form["account"]["name"]["#access"] = FALSE; }?> ]]> 92 Mon, 25 Nov 2013 14:44:09 -1000

    Global

    items_map.tpl.php