Problem/Motivation

Taxonomy Block only supports one block. It would be nice to at least support one block per vocabulary.

Proposed resolution

Patch in #778892-2: Multiple blocks implements one block for each selected vocabulary.

Remaining tasks

  • Needs review from maintainer.
  • Should write some tests.
  • Do a better job of cleaning up old variables when uninstalled.

User interface changes

  • User can select more than one vocabulary on the admin page.
  • The option to show the node count was moved to the block configuration page.
  • The path for the links was added to the block configuration page.

API changes

  • Changed the way variables were named (use double-underscore namespacing approach).

Original report by meecect

Maybe I'm just dense, but is there a way to have more than one taxonomy block? I would like to have 1 block for my 'tags' vocab and one for my 'categories' vocab. On the settings page, all I see is a way to select one vocab.

Comments

meecect’s picture

nm, now I see that it is listed on the project page that only 1 is supported. Are there any other modules that do this?

tedfordgif’s picture

Version: 6.x-1.0-beta4 » 7.x-1.0
Category: support » feature
Status: Active » Needs review
StatusFileSize
new9.5 KB

Here is a patch to 7.x-1.0 that makes this module support up to one block per vocabulary. The node count display and link path can be configured per-block.

deciphered’s picture

Status: Needs review » Needs work
+++ localmods/taxonomy_block/taxonomy_block.install	2011-08-11 14:13:54.624678619 -0400
@@ -8,6 +8,8 @@
+    ->condition('name', db_like('taxonomy_block__').'%', 'LIKE')

+++ localmods/taxonomy_block/taxonomy_block.module	2011-08-11 14:13:54.624678619 -0400
@@ -67,12 +67,73 @@
+  $url = variable_get('taxonomy_block__url_'.$delta, $default);
+  if (!is_array($url))
+    $url = $default;
...
+        variable_set('taxonomy_block__url_'.$delta, $url);
...
+    if (!$valid)
+      form_set_error('taxonomy_block__url_'.$delta, t('Please provide a valid internal drupal path for the URL.'));
...
+  else
+    variable_del('taxonomy_block__url_'.$delta);
+  if (!empty($edit['taxonomy_block__node_count_'.$delta]))
+    variable_set('taxonomy_block__node_count_'.$delta, $edit['taxonomy_block__node_count_'.$delta]);
+  else
+    variable_del('taxonomy_block__node_count_'.$delta);

@@ -80,17 +141,16 @@
+        variable_get('taxonomy_block__url_'.$delta, drupal_parse_url('taxonomy/term/%taxonomy_term')), ¶
+        (bool) variable_get('taxonomy_block__node_count_'.$delta, 1)

@@ -180,26 +240,33 @@
+      $title .= ' <span class=\"node-count">('.taxonomy_block_count_nodes_term($term->tid).')</span>';
...
+      foreach ($base_url['query'] as $key => $val)
+        $base_url['query'][$key] = str_replace('%taxonomy_term', $term->tid, $val);

A lot of minor Drupal coding standards issues, please refer to http://drupal.org/coding-standards

deciphered’s picture

Status: Needs work » Needs review
StatusFileSize
new12.58 KB

Rerolled patch so it applies via Drush make, also did some minor cleanup.

scottrigby’s picture

Status: Needs review » Needs work

The block node count option doesn't save if disabled.

Checkboxes need:

-    '#default_value'  => variable_get('taxonomy_block__machine_names', ''),
+    '#default_value'  => variable_get('taxonomy_block__machine_names', array()),

Minor spelling:

-        'info' => t('Taxonomy Blok: @name', array('@name' => $vocabs[$machine_name]->name)),
+        'info' => t('Taxonomy Block: @name', array('@name' => $vocabs[$machine_name]->name)),
BeaPower’s picture

@ 5 - Can you roll an updated patch, thanks.

BeaPower’s picture

StatusFileSize
new12.97 KB

Here's an updated patch, with the edits from #5

Taxoman’s picture

Component: Documentation » Code
Priority: Normal » Major
Status: Needs work » Needs review

(Leaving this issue/patch in the 1.0 trunk, as the subsequent updates of this module has extra code for multi-lingual support, which may mean more changes are needed for this patch. However, as that "new" multilingual support is totally breaking sites as per 1.3 (fixes has not been committed yet, wait for 1.4 until expecting something stable or working...), therefore better to keep this one against 1.0 for now.

Taxoman’s picture

Category: feature » task

On second thought, this functionality is clearly needed and was supported on previous platform versions, so this is more of a task than a feature request.

mahyarsbt’s picture

Hi
this is a good module and very useful.

but i think if this module structure changed to menu block structure is better.

I mean :

function taxonomy_block_menu() {
  if (module_exists('block')) {
    $items['admin/structure/block/add-taxonomy-block'] = array(
      'title' => 'Add taxonomy block',
      'description' => 'Add a new taxonomy block.',
      'page callback' => 'drupal_get_form',
      'page arguments' => array('taxonomy_block_add_block_form'),
      'access arguments' => array('administer blocks'),
      'type' => MENU_LOCAL_ACTION,
      'file' => 'taxonomy_block.admin.inc',
    );
    $default_theme = variable_get('theme_default', 'bartik');
    foreach (list_themes() as $key => $theme) {
      if ($key != $default_theme) {
        $items['admin/structure/block/list/' . $key . '/add-taxonomy-block'] = array(
          'title' => 'Add taxonomy block',
          'description' => 'Add a new taxonomy block.',
          'page callback' => 'drupal_get_form',
          'page arguments' => array('taxonomy_block_add_block_form'),
          'access arguments' => array('administer blocks'),
          'type' => MENU_LOCAL_ACTION,
          'file' => 'taxonomy_block.admin.inc',
        );
      }
    }
    $items['admin/structure/block/delete-taxonomy-block'] = array(
      'title' => 'Delete taxonomy block',
      'page callback' => 'drupal_get_form',
      'page arguments' => array('taxonomy_block_delete'),
      'access arguments' => array('administer blocks'),
      'type' => MENU_CALLBACK,
      'file' => 'taxonomy_block.admin.inc',
    );
  }
}

Can move "Taxonomy block" menu to admin>structure>blocks
and when click 'Add taxonomy block', user can add blocks from taxonomy unlimited with configuration to select vocabulary , select level/term/parent ... like 'menu block' module

mahyarsbt’s picture

Issue summary: View changes

Updated description to reflect new patch.

macmladen’s picture

First of all, this is a needed feature, no doubt about it.

However, I'm not too sure it should go into Add new taxonomy block (I know there are some other modules that go this way).

It seems to me more natural to be part of Vocabulary->Edit where could be check-box Enable this taxonomy as block.

It is more of a taxonomy feature than a block feature.