<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xml:base="http://interfaces.orgnsm.org/syndicate">

    <channel>

        <title>Organic Interfaces</title>

        <link>http://interfaces.orgnsm.org/syndicate</link>

        <description>Recent Web Design &amp; Info Code</description>

        <language>en</language>

        <pubDate>Sun, 24 Dec 2023 14:08:19 -1000</pubDate>

        <!--image>
            <url></url>
            <title></title>
            <link></link>
        </image-->

<item>
 <title>see what is accessing disk / force unmount disk</title>
 <link>http://interfaces.orgnsm.org/node/139</link>
 <description><![CDATA[
<pre><code>lsof | grep /Volumes/IMAJIN




diskutil unmountDisk force /Volumes/IMAJIN</code></pre>  ]]></description>
 <guid isPermaLink='false'>139</guid>
 <pubDate>Sun, 24 Dec 2023 14:08:19 -1000</pubDate>
 <comments></comments>
</item>

<item>
 <title>Find which file a function is defined in</title>
 <link>http://interfaces.orgnsm.org/node/135</link>
 <description><![CDATA[
<pre><code>&lt;?php

$reflFunc=new ReflectionFunction('name_of_function');

echo($reflFunc->getFileName().':'.$reflFunc->getStartLine());

?&gt;</code></pre>  ]]></description>
 <guid isPermaLink='false'>135</guid>
 <pubDate>Mon, 26 Dec 2016 10:42:09 -1000</pubDate>
 <comments></comments>
</item>

<item>
 <title>Custom Post Types</title>
 <link>http://interfaces.orgnsm.org/node/134</link>
 <description><![CDATA[
<h3>Adds custom post type called "Reviews"</h3>
<pre><code>&lt;?php
function create_post_type(){
  register_post_type('review',
    array(
      'labels'=&gt;array(
        'name'=&gt;__('Reviews'),
        'singular_name'=&gt;__('Review')
      ),
      'public'=&gt;true,
      'has_archive'=&gt;true,
      'capabilities'=&gt;array(
          'edit_post'=&gt;'edit_review',
          'edit_posts'=&gt;'edit_reviews',
          'publish_posts'=&gt;'publish_review',
          'read_post'=&gt;'read_review',
      ),
    )
  );
}
add_action('init','create_post_type');
?&gt;</code></pre>


<h3>Add abilities to "Reviews" post type</h3>
<pre><code>&lt;?php
function add_theme_caps(){
    $subscribers=get_role('subscriber');
    $subscribers-&gt;add_cap('edit_review');
    $subscribers-&gt;add_cap('edit_reviews');
    $subscribers-&gt;add_cap('publish_review');
    $subscribers-&gt;add_cap('read_review');
    $admins=get_role('administrator');
    $admins-&gt;add_cap('edit_review');
    $admins-&gt;add_cap('edit_reviews');
    $admins-&gt;add_cap('publish_review');
    $admins-&gt;add_cap('read_review');
}
add_action('admin_init','add_theme_caps');
?&gt;</code></pre>


<h3>Add custom fields to "Reviews" post type</h3>
<pre><code>&lt;?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('&lt;input');
        if($x==$review_rating) echo(' checked="checked"');
        echo(' type="radio" name="review_rating" id="review_rating_'.$x.'" value="'.$x.'"/&gt;&lt;label for="review_rating_'.$x.'"&gt;'.$x.'&lt;/label&gt;'."\n");

    }
}
add_action('save_post','save_details');
function save_details(){
  global $post;
  update_post_meta($post-&gt;ID,'review_rating',$_POST["review_rating"]);
}
?&gt;</code></pre>  ]]></description>
 <guid isPermaLink='false'>134</guid>
 <pubDate>Sun, 25 Dec 2016 13:03:50 -1000</pubDate>
 <comments></comments>
</item>

<item>
 <title>In the Weeds</title>
 <link>http://interfaces.orgnsm.org/node/71</link>
 <description><![CDATA[
<img src='http://interfaces.orgnsm.org/sites/interfaces.orgnsm.org/files/styles/medium/public/itw_homepage_2_0.png?itok=RmTuWEts' alt=''/>
  ]]></description>
 <guid isPermaLink='false'>71</guid>
 <pubDate>Tue, 06 Dec 2016 17:03:10 -1000</pubDate>
 <comments>http://interfaces.orgnsm.org/sites/interfaces.orgnsm.org/files/styles/large-landscape-or-portrait/public/itw_homepage_2_0.png?itok=zrQuef0l</comments>
</item>

<item>
 <title>Post referencing setup</title>
 <link>http://interfaces.orgnsm.org/node/132</link>
 <description><![CDATA[
<pre><code>&lt;?php


// Adds custom post type for Projects and Services

function create_post_type(){

  register_post_type('project',
    array(
      'labels' =&gt; array(
        'name' =&gt; __('Projects'),
        'singular_name' =&gt; __('Project')
      ),
      'taxonomies' =&gt; array('category'),
      'public' =&gt; true,
      'has_archive' =&gt; true,
      'capabilities' =&gt; array(
          'edit_post' =&gt; 'edit_project',
          'edit_posts' =&gt; 'edit_projects',
          'publish_posts' =&gt; 'publish_project',
          'read_post' =&gt; 'read_project',
      ),
      'supports' =&gt; array(
          'title','editor','thumbnail'
      ),
    )
  );

  register_post_type('service',
    array(
      'labels' =&gt; array(
        'name' =&gt; __('Services'),
        'singular_name' =&gt; __('Service')
      ),
      'public' =&gt; true,
      'has_archive' =&gt; true,
      'capabilities' =&gt; array(
          'edit_post' =&gt; 'edit_service',
          'edit_posts' =&gt; 'edit_services',
          'publish_posts' =&gt; 'publish_service',
          'read_post' =&gt; 'read_service',
      ),
      'supports' =&gt; array(
          'title','editor','thumbnail'
      ),
    )
  );

}

add_action('init','create_post_type');





function add_theme_caps(){

    $subscribers = get_role( 'subscriber' );

    //$subscribers-&gt;add_cap( 'edit_project' );
    //$subscribers-&gt;add_cap( 'edit_projects' );
    //$subscribers-&gt;add_cap( 'publish_project' );

    $subscribers-&gt;add_cap( 'read_project' );
    $subscribers-&gt;add_cap( 'read_service' );

    $admins = get_role( 'administrator' );

    $admins-&gt;add_cap( 'edit_project' );
    $admins-&gt;add_cap( 'edit_projects' );
    $admins-&gt;add_cap( 'publish_project' );
    $admins-&gt;add_cap( 'read_project' );

    $admins-&gt;add_cap( 'edit_service' );
    $admins-&gt;add_cap( 'edit_services' );
    $admins-&gt;add_cap( 'publish_service' );
    $admins-&gt;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-&gt;ID);
    $project_services=$custom['project_service'][0];
    $project_services=unserialize($project_services);
    $args=array(
        'post_type'=&gt;'service',
        'posts_per_page'=&gt;'200',
        'orderby'=&gt;'title',
        'order'=&gt;'ASC'
    );
    $loop=new WP_Query($args);
    while($loop-&gt;have_posts()):$loop-&gt;the_post();
        echo('&lt;div&gt;&lt;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('&gt;&lt;label for="project_service_'.get_the_ID().'"&gt;'.get_the_title(get_the_ID()).'&lt;/label&gt;&lt;/div&gt;');
    endwhile;
}



function save_details(){
    global $post;
    update_post_meta($post-&gt;ID,'project_service',$_POST["project_services"]);
}

add_action('save_post','save_details');




?&gt;</code></pre>  ]]></description>
 <guid isPermaLink='false'>132</guid>
 <pubDate>Thu, 01 Dec 2016 16:46:51 -1000</pubDate>
 <comments></comments>
</item>

<item>
 <title>Covidien Portal</title>
 <link>http://interfaces.orgnsm.org/node/36</link>
 <description><![CDATA[
<img src='http://interfaces.orgnsm.org/sites/interfaces.orgnsm.org/files/styles/medium/public/2014-02-03_1.png?itok=7A-XgR-3' alt=''/>
  ]]></description>
 <guid isPermaLink='false'>36</guid>
 <pubDate>Thu, 03 Nov 2016 14:38:17 -1000</pubDate>
 <comments>http://interfaces.orgnsm.org/sites/interfaces.orgnsm.org/files/styles/large-landscape-or-portrait/public/2014-02-03_1.png?itok=R5zFP4zs</comments>
</item>

<item>
 <title>Foster Care Training</title>
 <link>http://interfaces.orgnsm.org/node/131</link>
 <description><![CDATA[
<img src='http://interfaces.orgnsm.org/sites/interfaces.orgnsm.org/files/styles/medium/public/fostercaretraining_1.png?itok=1ZnS6HVK' alt=''/>
  ]]></description>
 <guid isPermaLink='false'>131</guid>
 <pubDate>Tue, 25 Oct 2016 10:58:38 -1000</pubDate>
 <comments>http://interfaces.orgnsm.org/sites/interfaces.orgnsm.org/files/styles/large-landscape-or-portrait/public/fostercaretraining_1.png?itok=RsX5KtlF</comments>
</item>

<item>
 <title>AG &amp; Associates</title>
 <link>http://interfaces.orgnsm.org/node/130</link>
 <description><![CDATA[
<img src='http://interfaces.orgnsm.org/sites/interfaces.orgnsm.org/files/styles/medium/public/agassociates_1.png?itok=AaONF7FC' alt=''/>
  ]]></description>
 <guid isPermaLink='false'>130</guid>
 <pubDate>Tue, 25 Oct 2016 10:57:52 -1000</pubDate>
 <comments>http://interfaces.orgnsm.org/sites/interfaces.orgnsm.org/files/styles/large-landscape-or-portrait/public/agassociates_1.png?itok=8e78XVFA</comments>
</item>

<item>
 <title>Calvin Associates</title>
 <link>http://interfaces.orgnsm.org/node/129</link>
 <description><![CDATA[
<img src='http://interfaces.orgnsm.org/sites/interfaces.orgnsm.org/files/styles/medium/public/calvin_2.png?itok=DIu4pBAi' alt=''/>
  ]]></description>
 <guid isPermaLink='false'>129</guid>
 <pubDate>Tue, 25 Oct 2016 10:57:28 -1000</pubDate>
 <comments>http://interfaces.orgnsm.org/sites/interfaces.orgnsm.org/files/styles/large-landscape-or-portrait/public/calvin_2.png?itok=zy0cDiNQ</comments>
</item>

<item>
 <title>Ferber Law</title>
 <link>http://interfaces.orgnsm.org/node/128</link>
 <description><![CDATA[
<img src='http://interfaces.orgnsm.org/sites/interfaces.orgnsm.org/files/styles/medium/public/ferberlaw_1.png?itok=zYe-z-en' alt=''/>
  ]]></description>
 <guid isPermaLink='false'>128</guid>
 <pubDate>Tue, 25 Oct 2016 10:41:45 -1000</pubDate>
 <comments>http://interfaces.orgnsm.org/sites/interfaces.orgnsm.org/files/styles/large-landscape-or-portrait/public/ferberlaw_1.png?itok=_Y6l_Vqr</comments>
</item>

<item>
 <title>Oakland Police</title>
 <link>http://interfaces.orgnsm.org/node/127</link>
 <description><![CDATA[
<img src='http://interfaces.orgnsm.org/sites/interfaces.orgnsm.org/files/styles/medium/public/oakland_police_1.png?itok=SFUlhrQs' alt=''/>
  ]]></description>
 <guid isPermaLink='false'>127</guid>
 <pubDate>Tue, 25 Oct 2016 10:41:24 -1000</pubDate>
 <comments>http://interfaces.orgnsm.org/sites/interfaces.orgnsm.org/files/styles/large-landscape-or-portrait/public/oakland_police_1.png?itok=NpLNZGYx</comments>
</item>

<item>
 <title>Orgnsm (ROOT)</title>
 <link>http://interfaces.orgnsm.org/node/78</link>
 <description><![CDATA[
<img src='http://interfaces.orgnsm.org/sites/interfaces.orgnsm.org/files/styles/medium/public/2015-09-25.png?itok=cpKoYP1B' alt=''/>
  ]]></description>
 <guid isPermaLink='false'>78</guid>
 <pubDate>Mon, 15 Aug 2016 22:54:27 -1000</pubDate>
 <comments>http://interfaces.orgnsm.org/sites/interfaces.orgnsm.org/files/styles/large-landscape-or-portrait/public/2015-09-25.png?itok=OEBSXJSX</comments>
</item>

<item>
 <title>Tru frame</title>
 <link>http://interfaces.orgnsm.org/node/137</link>
 <description><![CDATA[
<img src='http://interfaces.orgnsm.org/sites/interfaces.orgnsm.org/files/styles/medium/public/WEB%20CLIENTS_truframe.jpg?itok=l0yPzACD' alt=''/>
  ]]></description>
 <guid isPermaLink='false'>137</guid>
 <pubDate>Sat, 16 Jan 2016 12:16:43 -1000</pubDate>
 <comments>http://interfaces.orgnsm.org/sites/interfaces.orgnsm.org/files/styles/large-landscape-or-portrait/public/WEB%20CLIENTS_truframe.jpg?itok=o41yTW1n</comments>
</item>

<item>
 <title>Lotto-rithm</title>
 <link>http://interfaces.orgnsm.org/node/136</link>
 <description><![CDATA[
<img src='http://interfaces.orgnsm.org/sites/interfaces.orgnsm.org/files/styles/medium/public/WEB%20CLIENTS_lotto-rithm.jpg?itok=v3JAA01p' alt=''/>
  ]]></description>
 <guid isPermaLink='false'>136</guid>
 <pubDate>Sat, 16 Jan 2016 12:16:21 -1000</pubDate>
 <comments>http://interfaces.orgnsm.org/sites/interfaces.orgnsm.org/files/styles/large-landscape-or-portrait/public/WEB%20CLIENTS_lotto-rithm.jpg?itok=mWsgoSFc</comments>
</item>

<item>
 <title>Rate Your Customer / Rate My Contractor</title>
 <link>http://interfaces.orgnsm.org/node/133</link>
 <description><![CDATA[
<img src='http://interfaces.orgnsm.org/sites/interfaces.orgnsm.org/files/styles/medium/public/rate-your-customer-1.png?itok=9ZMlAO_Z' alt=''/>
  ]]></description>
 <guid isPermaLink='false'>133</guid>
 <pubDate>Fri, 25 Dec 2015 12:46:46 -1000</pubDate>
 <comments>http://interfaces.orgnsm.org/sites/interfaces.orgnsm.org/files/styles/large-landscape-or-portrait/public/rate-your-customer-1.png?itok=iCcMhL2y</comments>
</item>

<item>
 <title>IXIAS</title>
 <link>http://interfaces.orgnsm.org/node/125</link>
 <description><![CDATA[
<img src='http://interfaces.orgnsm.org/sites/interfaces.orgnsm.org/files/styles/medium/public/2016-03-23.png?itok=1_4V8ikr' alt=''/>
  ]]></description>
 <guid isPermaLink='false'>125</guid>
 <pubDate>Thu, 20 Aug 2015 15:21:39 -1000</pubDate>
 <comments>http://interfaces.orgnsm.org/sites/interfaces.orgnsm.org/files/styles/large-landscape-or-portrait/public/2016-03-23.png?itok=MaMyLOHQ</comments>
</item>

<item>
 <title>NeuroGenesix</title>
 <link>http://interfaces.orgnsm.org/node/19</link>
 <description><![CDATA[
<img src='http://interfaces.orgnsm.org/sites/interfaces.orgnsm.org/files/styles/medium/public/neuro_2009-11-22_1.png?itok=C_bNd0U1' alt=''/>
  ]]></description>
 <guid isPermaLink='false'>19</guid>
 <pubDate>Wed, 29 Jul 2015 01:55:27 -1000</pubDate>
 <comments>http://interfaces.orgnsm.org/sites/interfaces.orgnsm.org/files/styles/large-landscape-or-portrait/public/neuro_2009-11-22_1.png?itok=ZAApFV0d</comments>
</item>

<item>
 <title>Font-embed Rundown</title>
 <link>http://interfaces.orgnsm.org/node/126</link>
 <description><![CDATA[
<pre>TTF - Works in most browsers except IE and iPhone
EOT - IE only
WOFF - Compressed, emerging standard
SVG - iPhone/iPad</pre>  ]]></description>
 <guid isPermaLink='false'>126</guid>
 <pubDate>Sun, 28 Sep 2014 10:08:27 -1000</pubDate>
 <comments></comments>
</item>

<item>
 <title>Using jQuery flexslider with animated captions callback</title>
 <link>http://interfaces.orgnsm.org/node/124</link>
 <description><![CDATA[
<pre><code>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);
        },

    } );



} );</code></pre>


<pre><code>.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;
}</code></pre>  ]]></description>
 <guid isPermaLink='false'>124</guid>
 <pubDate>Thu, 04 Sep 2014 17:45:54 -1000</pubDate>
 <comments></comments>
</item>

<item>
 <title>Removes fields pending for deletion to uninstall a stuck module</title>
 <link>http://interfaces.orgnsm.org/node/121</link>
 <description><![CDATA[
<pre><code>DELETE FROM `field_config` WHERE `field_config`.`deleted` = 1;</code></pre>  ]]></description>
 <guid isPermaLink='false'>121</guid>
 <pubDate>Sun, 13 Jul 2014 19:37:35 -1000</pubDate>
 <comments></comments>
</item>

<item>
 <title>Reading/setting Drupal config variables</title>
 <link>http://interfaces.orgnsm.org/node/120</link>
 <description><![CDATA[
<pre><code>&lt;?php
function organic_context_config_page(){
    $form = array();
    $form['onthisdate_maxdisp'] = array(
        '#type' =&gt; 'textfield',
        '#title' =&gt; t('Maximum number of links'),
        '#default_value' =&gt; variable_get('onthisdate_maxdisp', 3),
        '#size' =&gt; 2,
        '#maxlength' =&gt; 2,
        '#description' =&gt; t("The maximum number of links to display in the block."),
        '#required' =&gt; TRUE,
    );
    return system_settings_form($form);
}
?&gt;</code></pre>  ]]></description>
 <guid isPermaLink='false'>120</guid>
 <pubDate>Sun, 13 Jul 2014 19:23:23 -1000</pubDate>
 <comments></comments>
</item>

<item>
 <title>Migrates multigroups in D6 to field collections in D7</title>
 <link>http://interfaces.orgnsm.org/node/119</link>
 <description><![CDATA[
<pre><code>&lt;?php

/////////////////// PAGE DEFINITIONS ///////////////////


function migrate_groups_menu(){
    $menu["migrate_groups"] = array(
        "title" =&gt; "Migrate grps",
        "description" =&gt; "....",
        "page callback" =&gt; "migrate_multigroup_to_collections",
        "access callback" =&gt; 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])
    -&gt;condition('entity_type', 'node')
    -&gt;condition('bundle', $content_type);
  $query-&gt;addExpression('DISTINCT entity_id', 'nid');
  $query-&gt;addExpression('revision_id', 'vid');
  $nodes_result = $query-&gt;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')
        -&gt;fields('field')
        -&gt;condition('entity_type', 'node')
        -&gt;condition('entity_id', $node-&gt;nid)
        -&gt;execute();

      foreach ($field_result as $field_item) {
        $multigroup_data[$field_item-&gt;delta][$field] = $field_item;
      }

    }

    // Step through the reconstructed multigroups, which are collections from now.
    foreach ($multigroup_data as $delta =&gt; $data) {
      // Create entry in field_collection_item table.
      $id = db_insert('field_collection_item')
        -&gt;fields(array('field_name' =&gt; $collection_field))
        -&gt;execute();

      // Attach collection field data to the node.
      db_insert('field_data_' . $collection_field)
        -&gt;fields(array(
          'entity_type' =&gt; 'node',
          'bundle' =&gt; $content_type,
          'entity_id' =&gt; $node-&gt;nid,
          'revision_id' =&gt; $node-&gt;vid,
          'language' =&gt; 'und',
          'delta' =&gt; $delta,
          $collection_field . '_value' =&gt; $id,
        ))
        -&gt;execute();

      // Go through all the fields in the multigroup.
      foreach ($data as $multigroup_field =&gt; $field_data) {
        // Reassign the fields in the multigroup from the node to the collection field instance.
        db_update('field_data_' . $multigroup_field)
          -&gt;fields(array(
            'entity_type' =&gt; 'field_collection_item',
            'bundle' =&gt; $collection_field,
            'entity_id' =&gt; $id,
            'revision_id' =&gt; $id,
            'delta' =&gt; 0,
          ))
          -&gt;condition('entity_type', 'node')
          -&gt;condition('entity_id', $node-&gt;nid)
          -&gt;condition('delta', $delta)
          -&gt;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])
    -&gt;condition('entity_type', 'node')
    -&gt;condition('bundle', $content_type);
  $query-&gt;addExpression('DISTINCT entity_id', 'nid');
  $query-&gt;addExpression('revision_id', 'vid');
  $nodes_result = $query-&gt;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')
        -&gt;fields('field')
        -&gt;condition('entity_type', 'node')
        -&gt;condition('entity_id', $node-&gt;nid)
        -&gt;execute();

      foreach ($field_result as $field_item) {
        $multigroup_data[$field_item-&gt;delta][$field] = $field_item;
      }

    }

    $id = 0;
    // Step through the reconstructed multigroups, which are collections from now.
    foreach ($multigroup_data as $delta =&gt; $data) {
      // Create entry in field_collection_item table.
      $id = db_insert('field_collection_item')
        -&gt;fields(array('field_name' =&gt; $collection_field, 'revision_id' =&gt; 0, 'archived' =&gt; 0))
        -&gt;execute();

      $revid = db_insert('field_collection_item_revision')
        -&gt;fields(array('item_id' =&gt; $id))
        -&gt;execute();

      db_update('field_collection_item')
          -&gt;fields(array('revision_id' =&gt; $revid))
          -&gt;condition('item_id', $id)
          -&gt;execute();


      // Attach collection field data to the node.
      db_insert('field_data_' . $collection_field)
        -&gt;fields(array(
          'entity_type' =&gt; 'node',
          'bundle' =&gt; $content_type,
          'entity_id' =&gt; $node-&gt;nid,
          'revision_id' =&gt; $node-&gt;vid,
          'language' =&gt; 'und',
          'delta' =&gt; $delta,
          $collection_field . '_value' =&gt; $id,
          $collection_field . '_revision_id' =&gt; $revid,
        ))
        -&gt;execute();

      // Attach collection field data to the node.
      db_insert('field_revision_' . $collection_field)
        -&gt;fields(array(
          'entity_type' =&gt; 'node',
          'bundle' =&gt; $content_type,
          'entity_id' =&gt; $node-&gt;nid,
          'revision_id' =&gt; $node-&gt;vid,
          'language' =&gt; 'und',
          'delta' =&gt; $delta,
          $collection_field . '_value' =&gt; $id,
          $collection_field . '_revision_id' =&gt; $revid,
        ))
        -&gt;execute();

      // Go through all the fields in the multigroup.
      foreach ($data as $multigroup_field =&gt; $field_data) {
        // Reassign the fields in the multigroup from the node to the collection field instance.
        db_update('field_data_' . $multigroup_field)
          -&gt;fields(array(
            'entity_type' =&gt; 'field_collection_item',
            'bundle' =&gt; $collection_field,
            'entity_id' =&gt; $id,
            'language' =&gt; 'und',
            'revision_id' =&gt; $revid,
            'delta' =&gt; 0,
          ))
          -&gt;condition('entity_type', 'node')
          -&gt;condition('entity_id', $node-&gt;nid)
          -&gt;condition('delta', $delta)
          -&gt;execute();

       db_delete('field_revision_' . $multigroup_field)
          -&gt;condition('entity_type', 'node')
          -&gt;condition('entity_id', $node-&gt;nid)
        -&gt;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";
}

?&gt;</code></pre>  ]]></description>
 <guid isPermaLink='false'>119</guid>
 <pubDate>Wed, 09 Jul 2014 00:20:20 -1000</pubDate>
 <comments></comments>
</item>

<item>
 <title>Drupal DB Query to find Children (Recursively)</title>
 <link>http://interfaces.orgnsm.org/node/114</link>
 <description><![CDATA[
<pre><code>&lt;?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;
}
?&gt;</code></pre>


<pre><code>&lt;?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 = "&lt;h3>Notes&lt;/h3>\n";
	$return .= "&lt;ul>\n";
	foreach( $db_query_spheres_via_project as $sphere ){
		if( isset($sphere->nid) ) $spheres_via_project[ $sphere->nid ] = $sphere;
		$return .= "&lt;li>&lt;a href=\"/node/".$sphere->nid."\">".$sphere->node_title."&lt;/a>&lt;/li>\n";
	}
	$return .= "&lt;/ul>\n";
    return $return;
}

return '&lt;div>&lt;strong>Associated Notes:&lt;/strong>&lt;/div>';
?&gt;</code></pre>


<pre><code>    // Obtain sphere nodes
    $query=new EntityFieldQuery();
    $query-&gt;entityCondition('entity_type','node')
          -&gt;entityCondition('bundle','sphere');
    $sephiroths=$query-&gt;execute();
    if(array_key_exists('node',$sephiroths))
        $sephiroths=entity_load('node',array_keys($sephiroths['node']));


    // Obtain path nodes
    $query=new EntityFieldQuery();
    $query-&gt;entityCondition('entity_type','node')
          -&gt;entityCondition('bundle','path');
    $paths=$query->execute();
    if(array_key_exists('node',$paths))
        $paths=entity_load('node',array_keys($paths['node']));
</code></pre>  ]]></description>
 <guid isPermaLink='false'>114</guid>
 <pubDate>Fri, 09 May 2014 01:21:13 -1000</pubDate>
 <comments></comments>
</item>

<item>
 <title>Similar by Taxonomy</title>
 <link>http://interfaces.orgnsm.org/node/113</link>
 <description><![CDATA[
<pre><code>&lt;ul class="item-list"&gt;
&lt;?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-&gt;tid);

	if( $term-&gt;name == arg(1) || array_key_exists( $term-&gt;tid,$terms_nood ) ){
		echo("&lt;li class=\"collapsed tag-category-".$popularityCategory."\"&gt;");
		echo("&lt;a href=\"/visual/".$term-&gt;name."\" class=\"active\"&gt;".$term-&gt;name."&lt;/a&gt;");
		echo("&lt;/li&gt;\n");
	}

}

?&gt;
&lt;/ul&gt;


&lt;?php
if(arg(0)=='node'&amp;&amp;isset($node)){
    $vocabularies = taxonomy_get_vocabularies();
    foreach( $vocabularies as $vocabulary ){
        if( $vocabularies ){
            $terms = taxonomy_node_get_terms_by_vocabulary($node,$vocabulary-&gt;vid);
            if( $terms ){
                echo('&lt;div&gt;');
                $links = array();
                echo('&lt;h3&gt;' . $vocabulary-&gt;name . '&lt;/h3&gt;');
                foreach( $terms as $term ){
                    $term_uri = taxonomy_term_uri($term);
                    $links[] = l($term-&gt;name,$term_uri['path'],array('rel'=&gt;'tag','title'=&gt;strip_tags($term-&gt;description)));
                }
                echo(implode(', ', $links));
                echo('&lt;/div&gt;');
            }
        }
    }
}
?&gt;


&lt;?php #if ($terms): ?&gt;
&lt;?php
$vocabularies = taxonomy_get_vocabularies();
foreach( $vocabularies as $vocabulary ){
	if( $vocabularies ){
		$terms = taxonomy_node_get_terms_by_vocabulary($node, $vocabulary-&gt;vid);
		if( $terms ){
			echo("&lt;div&gt;\n");
			$links = array();
			echo( "&lt;h3&gt;" . $vocabulary-&gt;name . "&lt;/h3&gt;\n" );
			foreach( $terms as $term )
				$links[] = l($term-&gt;name, taxonomy_term_path($term), array('rel' =&gt; 'tag', 'title' =&gt; strip_tags($term-&gt;description)));
			echo( implode(', ', $links) );
			echo("&lt;/div&gt;\n");
		}
	}
}
?&gt;</code></pre>  ]]></description>
 <guid isPermaLink='false'>113</guid>
 <pubDate>Mon, 28 Apr 2014 21:00:56 -1000</pubDate>
 <comments></comments>
</item>

<item>
 <title>Rename stuck field names</title>
 <link>http://interfaces.orgnsm.org/node/111</link>
 <description><![CDATA[
<pre><code>&lt;?php

$fields = array(
    'field_inspirational_imagery' =&gt; 'field_images',
);
 
// Loop through each of the fields/tables with the old name and change them
foreach($fields as $field_name =&gt; $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 =&gt; $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')
        -&gt;fields(
            array(
                'field_name' =&gt; $new_field_name,
            )
        )
        -&gt;condition('field_name', $field_name, '=')
    -&gt;execute();
 
    db_update('field_config_instance')
        -&gt;fields(
            array(
                'field_name' =&gt; $new_field_name,
            )
        )
        -&gt;condition('field_name', $field_name, '=')
    -&gt;execute();

} /// end foreach loop on fields... whew.

?&gt;</code></pre>  ]]></description>
 <guid isPermaLink='false'>111</guid>
 <pubDate>Fri, 21 Feb 2014 15:11:51 -1000</pubDate>
 <comments></comments>
</item>


    </channel>

</rss>