--- nodeasblock.module.orig 2009-02-26 14:05:40.000000000 +0100 +++ nodeasblock.module 2009-02-26 14:07:14.000000000 +0100 @@ -28,6 +28,7 @@ */ define('NODEASBLOCK_ALWAYS', 2); + /** * @} End of "Node as block visibility settings". */ @@ -77,7 +78,20 @@ '#return_value' => 1, '#description' => t('Allow users to make these nodes visible as sidebar blocks.'), ); - + + /* Adding by Florent J. : teaser or full node */ + $form['nodeasblockset']['nodeasblock_default_teaser'] = array( + '#type' => 'select', + '#multiple'=> FALSE, + '#title' => t('Display node mode'), + '#options' => array ( + 0 => t('Normal'), + 1 => t('Teaser') + ), + '#default_value' => variable_get('nodeasblock_default_teaser_'.$node_type, NODEASBLOCK_TEASER), + ); + /* End adding by Florent J. */ + // Regions to select from default theme. $regions = system_region_list($theme); $form['nodeasblockset']['nodeasblock_region'] = array( @@ -138,9 +152,12 @@ $node->nid = 0; } + /* Adding by Florent J. : teaser or full node */ if (!isset($node->nodeasblock)) { - $node->nodeasblock = 0; + $node->nodeasblock = 0; + $node->nodeasblock_teaser = variable_get('nodeasblock_default_teaser_'.$node->type, NODEASBLOCK_TEASER); } + /* End adding by Florent J. */ $form['nodeasblockset'] = array( '#type' => 'fieldset', @@ -159,6 +176,18 @@ '#description' => t('Check this box to create a block for this node. The block will contain the teaser.'), ); + /* Adding by Florent J. : teaser or full node */ + $form['nodeasblockset']['teaser'] = array( + '#type' => 'select', + '#multiple' => FALSE, + '#options' => array ( + 0 => t('Normal'), + 1 => t('Teaser') + ), + '#default_value' => $node->nodeasblock_teaser, + ); + /* End adding by Florent J. */ + // Slight change to the UI if the block is required. if (variable_get("nodeasblock_$node->type", NODEASBLOCK_PER_NODE) == NODEASBLOCK_ALWAYS) { $form['nodeasblockset']['nodeasblock']['#default_value'] = TRUE; @@ -229,7 +258,16 @@ function nodeasblock_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) { switch ($op) { case 'load': - $node->nodeasblock = db_result(db_query('SELECT nid FROM {nodeasblock} WHERE nid = %d', $node->nid)); + /* Adding by Florent J. : teaser or full node */ + $nodeasblock = db_fetch_object(db_query('SELECT nid, teaser FROM {nodeasblock} WHERE nid = %d', $node->nid)); + if ($nodeasblock) { + $node->nodeasblock = 1; + $node->nodeasblock_teaser = $nodeasblock->teaser; + } else { + $node->nodeasblock = 0; + $node->nodeasblock_teaser = 1; + } + /* End adding by Florent J. */ break; case 'insert': @@ -239,8 +277,10 @@ // First delete the entry from the table if it exists. db_query('DELETE FROM {nodeasblock} WHERE nid = %d', $node->nid); if ($node->nodeasblockset['nodeasblock'] || variable_get("nodeasblock_$node->type", NODEASBLOCK_DISABLED) == NODEASBLOCK_ALWAYS) { - db_query('INSERT INTO {nodeasblock} VALUES (%d)', $node->nid); - drupal_set_message(t('The block configuration has been saved.')); + /* Adding by Florent J. : teaser or full node */ + db_query('INSERT INTO {nodeasblock} VALUES (%d, %d)', $node->nid, $node->nodeasblockset['teaser']); + /* End adding by Florent J. */ + drupal_set_message(t("The block configuration has been saved.")); nodeasblock_save_block($node); } } @@ -307,7 +347,7 @@ if ($node = node_load(array('nid' => $delta, 'status' => 1))) { // Don't show nodes in other languages than current. Integration with i18n node languages. global $language; - if (empty($node->language) || $node->language == $language) { + if (empty($node->language) || $node->language == $language->language) { return array( 'subject' => l($node->title, 'node/'. $node->nid), 'content' => theme('nodeasblock', $node), @@ -324,7 +364,11 @@ */ function theme_nodeasblock($node) { // Get an HTML representation of the themed node. - $content = node_view($node, TRUE, TRUE, TRUE); + if ($node->nodeasblock_teaser == 1) { + $content = node_view($node, TRUE, TRUE, TRUE); + } else { + $content = node_view($node, FALSE, TRUE, TRUE); + } // If the user has permissions to edit the node, then add a link. if (node_access('update', $node)) { @@ -333,3 +377,4 @@ return $content; } +