Items
Nodes Posts Things
Blocks
items_blocks.tpl.php
- Using jQuery flexslider with animated captions callback 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... Code JQuery 2014
- Topics Types Topics Attributes 2014 8 26
- MySQL DELETE FROM `field_config` WHERE `field_config`.`deleted` = 1;... Topics Frameworks Information Structuring 2014 1
- Removes fields pending for deletion to uninstall a stuck module DELETE FROM `field_config` WHERE `field_config`.`deleted` = 1;... Drupal MySQL 2014
- Reading/setting Drupal config variables <?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' =&... Code Drupal 2014
- Migrates multigroups in D6 to field collections in D7 <?php /////////////////// PAGE DEFINITIONS /////////////////// function migrate_groups_menu(){ $menu["migrate_groups"] = array( "title" => "Migrate grps", "description" => "....", "page callback" => "migrate_multigroup_to_collections", "access callback" => TRUE... Code Drupal 2014
- Google Frameworks Topics 2014 2
- Organic Connectivity Module Topics Frameworks Template Coding Drupal 2014 6
- Drupal DB Query to find Children (Recursively) <?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... Code Drupal PHP Template Coding 2014
- Similar by Taxonomy <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... Code Drupal Template Coding 2014
Nodes
items_nodes.tpl.php
-
Using jQuery flexslider with animated captions callback
Submitted by orgnsm on Thu, 09/04/2014 - 17:45jQuery(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
Submitted by orgnsm on Thu, 07/17/2014 - 01:42Context:Connection:Attribute Type:TypesConnection:Attribute Type:TypesConnection:Attribute Type:TypesImages: -
Removes fields pending for deletion to uninstall a stuck module
Submitted by orgnsm on Sun, 07/13/2014 - 19:37 -
Reading/setting Drupal config variables
Submitted by orgnsm on Sun, 07/13/2014 - 19:23<?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
Submitted by orgnsm on Wed, 07/09/2014 - 00:20<?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"; } ?>
-
Organic Connectivity Module
Submitted by orgnsm on Mon, 05/12/2014 - 20:44Context:Connection:Attribute Type:TypesConnection:Attribute Type:TypesInstallation URL:http://connectivity.orgnsm.orgImages: -
Drupal DB Query to find Children (Recursively)
Submitted by orgnsm on Fri, 05/09/2014 - 01:21Context:Connection:Attribute Type:Types<?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
Submitted by orgnsm on Mon, 04/28/2014 - 21:00Context:Connection:Attribute Type:Types<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"); } } } ?>
Table
items_table.tpl.php
ID | Images/Body | Types | Title | Subjects | Attributes | 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 |
|
EDIT | ||||
115 | Organic Connectivity Module |
|
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 |
Rotator
items_cinema.tpl.php
-
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: ... Code Using jQuery flexslider with animated captions callback JQuery
-
<?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); } ?>... Code Reading/setting Drupal config variables Drupal
-
<?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 $fi... Code Migrates multigroups in D6 to field collections in D7 Drupal
-
<?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 ... Code Drupal DB Query to find Children (Recursively) Drupal PHP Template Coding
-
<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... Code Similar by Taxonomy Drupal Template Coding
RSS
items_syndicate.tpl.php
Organic Interfaces http://interfaces.orgnsm.org/syndicateRecent Web Design & Info Code en Thu, 04 Sep 2014 17:45:54 -1000 Using jQuery flexslider with animated captions callback http://interfaces.orgnsm.org/node/124jQuery(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;
}
]]>
DELETE FROM `field_config` WHERE `field_config`.`deleted` = 1;
]]><?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);
}
?>
]]><?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";
}
?>
]]><?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']));
]]><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");
}
}
}
?>
]]>